Laravel: Difference between revisions
Adamcolton (talk | contribs) |
Adamcolton (talk | contribs) No edit summary |
||
| Line 20: | Line 20: | ||
== Illuminate/html == | == Illuminate/html == | ||
composer require illuminate/html | composer require illuminate/html | ||
Then in config/app.php, add 'Illuminate\Html\HtmlServiceProvider' to the providers array and 'Form' => 'Illuminate\Html\FormFacade' to the aliases array. | Then in config/app.php, add 'Illuminate\Html\HtmlServiceProvider' to the providers array and 'Form' => 'Illuminate\Html\FormFacade' to the aliases array. | ||
[https://laravel.com/docs/4.2/html This] seems to be the most up-to-date documentation. | |||
== Request == | == Request == | ||
| Line 30: | Line 29: | ||
$foo = Request::get('foo'); | $foo = Request::get('foo'); | ||
Gets all inputs from get and post. | Gets all inputs from get and post. | ||
Good shorthand | |||
$input = Request::all(); | |||
SomeModel::create($input); | |||
== Eloquent == | |||
The $fillable property limits which properties can be assigned. | |||
Revision as of 23:30, 21 January 2016
Implicit Route Binding
From this video
Route::get('users/{user}', function(App\User $user){
return $user;
});
If the arg name matches the token, it will magic that value into place. With the type hinting, it will find a user with the primary key given in the url.
To use something other than the primary key, you have to add a route binding in RouteServiceProvider.
Auth
php artisan make:auth
Creates a bunch of views, routes and adds a controller.
Easiest is to use 'sendmail'. Make sure to set 'from' in config/mail.php.
Homestead
I'll need to try setting up a homestead instance on AWS with Vagrant. Could be useful to know for other projects too.
Illuminate/html
composer require illuminate/html
Then in config/app.php, add 'Illuminate\Html\HtmlServiceProvider' to the providers array and 'Form' => 'Illuminate\Html\FormFacade' to the aliases array.
This seems to be the most up-to-date documentation.
Request
$input = Request::all();
$foo = Request::get('foo');
Gets all inputs from get and post.
Good shorthand
$input = Request::all(); SomeModel::create($input);
Eloquent
The $fillable property limits which properties can be assigned.