DEV Community

Discussion on: Laravel Form Request Tips & Tricks.

Collapse
 
secmohammed profile image
mohammed osama

Hello Deric, I appreciate that article is beneficial to you 😍
I haven't used Lumen, but there might be something missing, that to access the model instance inside your form request, your route has to be something like that
/posts/{post}
and then you can access it using $this->post or $this->route('post'), bear in mind that naming the route must be same as the name of the property you try to retrieve.

Collapse
 
dericlima profile image
Deric

Hello Mohammed, I found out what the issue was. Actually it's a bug that's happening with Lumen only during tests.

When you try to access the model with $this->route('model') during tests, a array is being returned instead, which makes the code to break.

Everything is clear now. Thanks for your time.

If you are interested about the issue, more details here: github.com/laravel/lumen-framework...