29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Upgrade Guide 28<br />

Route Filters<br />

Copy your filter bindings from app/filters.php and place them into the boot() method of<br />

app/Providers/RouteServiceProvider.php. Add use Illuminate\Support\Facades\Route; in<br />

the app/Providers/RouteServiceProvider.php in order to continue using the Route Facade.<br />

You do not need to move over any of the default Laravel 4.0 filters such as auth and csrf; they’re<br />

all here, but as middleware. Edit any routes or controllers that reference the old default filters (e.g.<br />

['before' => 'auth']) and change them to reference the new middleware (e.g. ['middleware' =><br />

'auth'].)<br />

Filters are not removed in Laravel 5. You can still bind and use your own custom filters using before<br />

and after.<br />

Global CSRF<br />

By default, CSRF protection is enabled on all routes. If you’d like to disable this, or only manually<br />

enable it on certain routes, remove this line from App\Http\Kernel’s middleware array:<br />

.<br />

1 'App\Http\Middleware\VerifyCsrfToken',<br />

If you want to use it elsewhere, add this line to $routeMiddleware:<br />

.<br />

1 'csrf' => 'App\Http\Middleware\VerifyCsrfToken',<br />

Now you can add the middleware to individual routes / controllers using ['middleware' => 'csrf']<br />

on the route. For more information on middleware, consult the full documentation.<br />

Eloquent Models<br />

Feel free to create a new app/Models directory to house your Eloquent models. Again, add this<br />

directory to the classmap directive of your composer.json file.<br />

Update any models using SoftDeletingTrait to use Illuminate\Database\Eloquent\SoftDeletes.<br />

Eloquent Caching<br />

Eloquent no longer provides the remember method for caching queries. You now are responsible<br />

for caching your queries manually using the Cache::remember function. For more information on<br />

caching, consult the full documentation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!