middleware in laravel

Solutions on MaxInterview for middleware in laravel by the best coders in the world

showing results for - "middleware in laravel"
Paloma
01 Oct 2017
1php artisan make:middleware nameOfMiddleware
Sara
22 Mar 2016
1class UserController extends Controller
2{
3    /**
4     * Instantiate a new controller instance.
5     *
6     * @return void
7     */
8    public function __construct()
9    {
10        $this->middleware('auth');
11
12        $this->middleware('log')->only('index');
13
14        $this->middleware('subscribed')->except('store');
15    }
16}
Nicolò
09 Oct 2019
1public function __construct(User $user)
2{
3  	$this->user = $user;
4  
5    $this->middleware(function ($request, $next) {
6        $user = auth()->user();
7        if ($user) {
8          	$this->user = $user;
9        }
10      
11        return $next($request);
12    });
13}
Reza
02 May 2016
1class UserController extends Controller
2{
3    /**
4     * Instantiate a new controller instance.
5     *
6     * @return void
7     */
8    public function __construct()
9    {
10        $this->middleware(function ($request, $next) {
11    		return $next($request);
12		});
13        $this->middleware('auth');
14        $this->middleware('log')->only('index');
15        $this->middleware('subscribed')->except('store');
16        
17    }
18}
Jana
14 Sep 2016
1<?php
2
3namespace App\Http\Middleware;
4
5use Closure;
6
7class BeforeMiddleware
8{
9    public function handle($request, Closure $next)
10    {
11        // Perform action
12
13        return $next($request);
14    }
15}
16
17
Leanne
29 Sep 2016
1<?php
2
3namespace App\Http\Middleware;
4
5use Closure;
6
7class CheckType
8{
9    public function handle($request, Closure $next)
10    {
11        // Perform action
12
13        return $next($request);
14    }
15}
similar questions
queries leading to this page
middleware in laravel