M
M
Mikhail2021-01-12 22:34:12
Laravel
Mikhail, 2021-01-12 22:34:12

Why does the middleware route return a model in one case, and INT (number) in the other?

Это пример middleware
Если пройти по первому роуту, то в middleware я получу модель с указанным в роуте id
А если пройти по второму роуту то я получаю просто цифру id
public function handle(Request $request, Closure $next, string $entity)
    {
        $check = $request->route($entity);
        dd($check);
        return $next($request);
    }


Here is an example of a route
Route::prefix('{id}')->middleware('myCheck:mymodel')->group(static function () {
    Route::get('/', [myController::class, 'detail'] );
    // Тут в мидле я получаю модель с id из роута

    Route::get('/list', [myController::class, 'get'] );
    // А тут в мидле я получаю просто интеджер id
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question