Answer the question
In order to leave comments, you need to log in
How to take route name in laravel in middleware?
routes.php
Route::group(['middleware' => 'access'], function () {
Route::resource('some', 'SomeController');
});
namespace App\Http\Middleware;
use Closure;
class AccessMidleware
{
public function handle($request, Closure $next)
{
dd(\Route::currentRouteName()); //К сожалению тут null
//return $next($request);
}
}
protected $routeMiddleware = [
...
'access'=>'App\Http\Middleware\AccessMidleware'
];
Answer the question
In order to leave comments, you need to log in
So you don't have a route name set.
Try asking it like this:
Route::group(['middleware' => 'access', "as" => "RouteName"], function () {
Route::resource('some', 'SomeController');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question