“Laravel Middleware” Code-Antworten

Laravel Middleware im Konstruktor

public function __construct(User $user)
{
  	$this->user = $user;
  
    $this->middleware(function ($request, $next) {
        $user = auth()->user();
        if ($user) {
          	$this->user = $user;
        }
      
        return $next($request);
    });
}
Almabek

Laravel Make: Middleware

php artisan make:middleware AdminMiddleware
Different Dogfish

Befehl zum Erstellen von Middleware in Laravel

php artisan make:middleware MiddlewreName
Isaac

Laravel Middleware

Route::get('/profile', function () {
    //
})->middleware('auth');
Poor Pigeon

Laravel Make: Middleware

public function handle($request, Closure $next)
{
    if ($request->user()->type != 'A')
    {
        return redirect('home');
    }

    return $next($request);
}
Different Dogfish

Laravel Make: Middleware

Route::group(['middleware' => 'App\Http\Middleware\AdminMiddleware'], function()
{
    Route::get ('/admin', ['uses' => 'AdminController@index', 'before' => 'admin']); 

});
Different Dogfish

Ähnliche Antworten wie “Laravel Middleware”

Fragen ähnlich wie “Laravel Middleware”

Weitere verwandte Antworten zu “Laravel Middleware” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen