Filters in Laravel 5

后端 未结 8 1006
南笙
南笙 2021-01-31 08:12

How do we make filters in Laravel 5? Is the idea of filters going away?

8条回答
  •  不知归路
    2021-01-31 08:40

    For the comment on before/after.

    From the link above :

    In Middleware..

    #Before
    public function handle($request, Closure $next)
    {
       //Do stuff
       return $request;
    }
    
    #After
    public function handle($request, Closure $next)
    {
       $response = $next($request);
    
      // Do stuff {on $response}
       return $response;
    }
    

    Using ['middleware' => 'shortName'] should treat it accordingly.

提交回复
热议问题