Skip to content

Instantly share code, notes, and snippets.

@Denkong
Last active August 28, 2018 08:47
Show Gist options
  • Select an option

  • Save Denkong/04bd2de3efb2ca3429d73d690d406dab to your computer and use it in GitHub Desktop.

Select an option

Save Denkong/04bd2de3efb2ca3429d73d690d406dab to your computer and use it in GitHub Desktop.
LARAVEL - посредники
app/Http/Middleware/
php artisan make:middleware OldMiddleware - создание
Пример
if ($request->input('age') < 200)
{
return redirect('/');
}
В Kernel.php
app\http\kernel.php
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'myAdmin' => Middleware\Access::class,
'myAdmin2' => Middleware\Access2::class,
];
В маршрутизаторе
Route::get('/admin',['uses'=>'HomeController@MyAdmin','middleware'=>'myAdmin']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment