I have made a custom Request for validation and i don't know how to get the Model id on update.
I'm using route model binding and form model binding but this models id is not shown when i hit this Request for validation and i make
dd($this);
all fields are shown except the model id.
use route() method on request to retrive the route parameter
dd($this->route('param_name'));
if your route is like /users/{user_id}
then $this->route('user_id');
will give you the parameter user_id value in request if you have bind custom parameter name in route model binding use that parametername in route() method
for ex. Route::model('user', App\User::class);
then use $this->route('user');
to retrive the user model directly.
PS. $this means you should be in your Request class where you define rules() and messages() method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With