R
R
Romi2021-10-22 00:05:12
Laravel
Romi, 2021-10-22 00:05:12

Model binding does not work without adding middleware('web') to the route - how so?

Model binding did not want to work in any way until I added ->middleware('web') to the route.

I found the solution by googling here: https://tyapk.ru/blog/post/laravel-route-model-bin..

But this is bullshit ! ))))))

Why doesn't it work without it? Who had it? Got it? What exactly is the problem? And how to remove this crutch from there?

Thank you.

upd: it turned out that ->middleware('api') is also good )) I analyze it further))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NubasLol, 2021-10-22
@romicohen

https://laravel.com/api/5.5/Illuminate/Routing/Mid...
Try adding this to your routes, you can do it where you registered

But I have a "self-made" file with routes))

R
Romi, 2021-10-22
@romicohen

In general, I just added middleware('api') to the route group, as I understand it, this is the best solution in this situation.
Thanks to all! Especially NubasLol

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question