Answers for "laravel middleware group"

PHP
1

laravel middleware group

Route::middleware(['first', 'second'])->group(function () {
    Route::get('/', function () {
        // Uses first & second middleware...
    });

    Route::get('/user/profile', function () {
        // Uses first & second middleware...
    });
});
Posted by: Guest on January-05-2021
0

middleware command in laravel

php artisan make:middleware NameOfTheMiddleware
Posted by: Guest on December-11-2020
1

laravel middleware

<?php

namespace App\Http\Middleware;

use Closure;

class CheckAge
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($request->age <= 200) {
            return redirect('home');
        }

        return $next($request);
    }
}
Posted by: Guest on October-27-2020

Browse Popular Code Answers by Language