Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yougotnet's avatar

Route Model Binding isn't populating the model

It's returning a model but not being populated.

web.php

Route::resource('lineitems', 'LineItemController');

My post (DELETE) is:

/lineitems/43

My function is:

public function destroy(LineItem $lineItem) { dd($lineItem); }

ID 43 does exists The dd returns a model but not data in the model; meaning id 43 is not populate in the model.

0 likes
4 replies
Cronix's avatar

Do you happen to have a getRouteKeyName() method in the LineItem model that is returning something other than id?

tykus's avatar
tykus
Best Answer
Level 104

Does you route wildcard match the param exactly?

Route::delete(‘line items/{lineItem}’, //...
yougotnet's avatar

tykus got it! The params did not match exactly.

tykus's avatar

Great. Please mark it solved

Please or to participate in this conversation.