Answer the question
In order to leave comments, you need to log in
Laravel model binding?
Tell me, when binding a model, the variable that I accept in the model should be called the same as in the route?
I.e:
Route::get('entity/{id}', '[email protected]');
class EntityController {
public function edit(Entity $id)
{
//code
}
}
$id->remove();
Answer the question
In order to leave comments, you need to log in
No. Model binding is when in your routes you have a BlogModel model under a certain {my_model} line.
// Provider
$toute->bind('my_model', Blog::class);
// Route
Route::get('entity/{my_model}', '[email protected]');
// Controller
class EntityController {
public function edit(Blog $model)
{
//code
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question