php - Upgrading Laravel from 4.2 to 5. How do I get a filter to work? -
i have method in filters.php in laravel 4.2 app looks this:
// clean/self-updating urls property route::filter('property-slug', function($route, $req) { $listing = $route->parameter('listing'); if ($route->parameter('metainfo') != $listing->metainfo) { return redirect::route('listing.full', [$listing->mlsnumber, $listing->metainfo]); } });
all allow me type in mydomain.com/property/21938281 (or mls number) , redirects nice url address slug (e.g. mydomain.com/property/21938281-123-main-street
where put new filters now? see there middleware before , after i'm not sure how particular 1 work since doesn't fit before or after.
create middleware:
php artisan make:middleware adminmiddleware
modify needs.
open app/http/kernel.php
, add like:
protected $routemiddleware = [ 'auth' => \app\http\middleware\authenticate::class, 'auth.basic' => \illuminate\auth\middleware\authenticatewithbasicauth::class, 'guest' => \app\http\middleware\redirectifauthenticated::class, 'admin' => \app\http\middleware\adminmiddleware::class ];
use in routes.php
:
route::get('admin/accounts', ['middleware' => 'admin', function () { // }]);
i had move filters middleware few days ago, since deprecated in 5.1.
Comments
Post a Comment