laravel-4

i have error in laravel on function /vendor/guzzlehttp/psr7/src/functions.php on line 77 [duplicate]

十年热恋 提交于 2019-12-05 14:28:24
This question already has an answer here : Difference in accessing arrays in PHP 5.3 and 5.4 or some configuration mismatch? (1 answer) Closed 4 years ago . I upload laravel 4 files on shared server and then i see this error. Parse error: syntax error, unexpected '[' in . /vendor/guzzlehttp/psr7/src/functions.php on line 77 in line 77: function stream_for($resource = '', array $options = []) Short array syntax [] was added in PHP 5.4, so I guess you're running some older version of PHP on the shared server. Normally replacing [] with array() would help, but here it is an external vendor

Laravel/Carbon Timestamp 0000-00-00 00:00:00 or Unexpected data found. Unexpected data found. Data missing

烂漫一生 提交于 2019-12-05 14:26:24
I have a timestamp in the DB and am trying to get the swine to save. I either get an issue where the MySQL timestamp is blank or I get an error. The format posted is UK standard. Posting data, I have tried some of the following: $user['crb_date'] = Carbon::createFromFormat('d/m/Y', $data['crb_date']); $user['crb_date'] = Carbon::createFromFormat('d/m/Y', $data['crb_date'])->toDateTimeString(); // Plus many other more std date(), strtodate() combos On my Model, I have custom getDates which will convert the dates to Carbon: public function getDates() { return [ 'last_login', 'created_at',

Laravel 4 get image from url

删除回忆录丶 提交于 2019-12-05 14:14:33
OK so when I want to upload an image. I usually do something like: $file = Input::file('image'); $destinationPath = 'whereEver'; $filename = $file->getClientOriginalName(); $uploadSuccess = Input::file('image')->move($destinationPath, $filename); if( $uploadSuccess ) { // save the url } This works fine when the user uploads the image. But how do I save an image from an URL??? If I try something like: $url = 'http://www.whereEver.com/some/image'; $file = file_get_contents($url); and then: $filename = $file->getClientOriginalName(); $uploadSuccess = Input::file('image')->move($destinationPath,

Laravel 4: where is to_array()?

泪湿孤枕 提交于 2019-12-05 13:28:34
Man, this is getting frustrating! In Laravel 4, using Eloquent, this works: var_dump(Worker::find(1)); . But if I try to use to_array() , it falls apart: var_dump(Worker::find(1)->to_array()); . This throws the following exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Database\Query\Builder' does not have a method 'to_array' Method in Laravel 4 are now camelCased var_dump(Worker::find(1)->toArray()); 来源: https://stackoverflow.com/questions/14285182/laravel-4-where-is-to-array

Laravel, using packages with PSR-4 gives message “No hint path defined for”

亡梦爱人 提交于 2019-12-05 12:54:11
Im using Laravel 4.1 and starting a package (subby) that is using PSR-4 standard. When I try to render any view with: return View::make('subby::user.login'); I get the message: No hint path defined for [subby] I've red many things, but those were usually typo problems The problem is in the usage of the PSR-4 Since Laravel default is PSR-0 it assumes that the resources (views etc) of a package will be 2 levels up from where the package service provider is. Ex: src ├── config ├── lang ├── migrations ├── Ghunti │ └── Subby │ └── SubbyServiceProvider.php ├── routes.php └── views └── user └── login

Laravel 4 controller tests - ErrorException after too many $this->call() - why?

可紊 提交于 2019-12-05 12:34:53
I'd greatly appreciate some help regarding a Laravel 4 issue I'm experiencing. I'm testing controller routes, specifically a controller that is responsible for routing responses for a questionnaire. I'm testing scenarios such as: the user attempting to skip a question, the user requesting a question that doesn't exist... etc. The tests that I've written for all scenarios up until now work as expected using PHPunit. The test I'm currently writing involves several $this->call() or $this->client->request() executions and that's where things break down. If I execute $this->call() or $this->client-

Form Model Binding for checkboxes

白昼怎懂夜的黑 提交于 2019-12-05 12:33:44
I'm using Laravel 4.1 and in my app I need to show a form with pre filled checkboxes. But I try to do it with using Form Model Binding, it doesn't work. {{ Form::model($user, array('route' => 'settings-notify')) }} <div class="formRow form-horizontal_row"> {{ Form::checkbox('notify_visit', '1') }} </div> <div class="formRow form-horizontal_row"> {{ Form::checkbox('notify_rate', '1') }} </div> <div class="formSubmit"> {{ Form::submit('Save') }} </div> {{ Form::close() }} Is there any way to make it working? Works fine for me, here's a test I just did here: Route::get('test', function() { $user

Relationship method must return an object of type Illuminate\\Database\\Eloquent\\Relations\\Relation from model call by not view in Laravel 4

笑着哭i 提交于 2019-12-05 12:28:27
I have a model, Ability, which belongs to another model AbilityType. <?php class Ability extends Eloquent { public function abilityType() { return $this->belongsTo('AbilityType'); } public function name() { return $this->abilityType->name; } } I can make this call in my blade template successfully: $ability->abilityType->name But when I make that same call in my Ability model, it throws an exception: ErrorException Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation Do the dynamic properties differ in behavior between view and model layer? What am

Laravel 4: how to remember a user when logging him in using Auth::login

眉间皱痕 提交于 2019-12-05 12:13:53
My users can login using social options (Facebook, Twitter) and so I don't use the Auth::attempt() method, but the Auth::login() . How can I remember my users so the don't have to login every time they restart the browser? It is not in the docs, but if you look at the code; public function login(UserInterface $user, $remember = false) So just do Auth::login($user, true); 来源: https://stackoverflow.com/questions/15051979/laravel-4-how-to-remember-a-user-when-logging-him-in-using-authlogin

How to add classes to Laravel 4 Forms

随声附和 提交于 2019-12-05 11:51:43
问题 Probably, it is a simple answer but I cannot find any documentation regarding this. I have laid out a form using Laravel 4 and it seems to be working fine but now I need to style it. How can I add classes to the form when its using blade? {{ Form::open(array('url' => 'foo/bar')) }} I have a class set up for the form and the buttons but I am not sure how to add it to the blade template. 回答1: You may try this {{ Form::open(array('url' => url('foo/bar'), 'class'=>'form', 'id'=>'frmFoo', 'style'=