Laravel model binding?

Tell me, when binding model, the variable that I take in the model, should be named as in the router?
That is:
Route::get('entity/{id}', 'EntityController@edit');

class EntityController {
 public function edit(Entity $id)
{
//code
}
}

In the above example, the edit method, I should call it the variable $id? With a different name, it doesn't work or it I something not so do? At the docks everywhere the name of the variable matches the name in the router and is not very logical:
$id->remove();
July 9th 19 at 13:44
1 answer
July 9th 19 at 13:46
Solution
No. Binding model - is when the ranting and under certain {my_model} line clogged BlogModel model.

// Provider
$toute->bind('my_model', Blog::class);

// Route
Route::get('entity/{my_model}', 'EntityController@edit');

// Controller
class EntityController {
 public function edit(Blog $model)
{
//code
}
}
Well, in my case, be sure to call the incoming variable as well as in the router? - rupert_Weissnat79 commented on July 9th 19 at 13:49
: And you RouteServiceProvider did the binding? Show a piece of code? (If Yes) - jules_Nolan10 commented on July 9th 19 at 13:52
For such variable names you other developers will abuse $id->remove();. Call a spade a spade. As well easier. $entity->remove(); - jules_Nolan10 commented on July 9th 19 at 13:55
: I was asking that is transmitted in the route id, and accepted for an entity instance. - rupert_Weissnat79 commented on July 9th 19 at 13:58
https://laravel.com/docs/5.2/routing#route-model-b... that's what I say - rupert_Weissnat79 commented on July 9th 19 at 14:01
In 5.2 version of the implicit binding. And I tell you about the obvious. If you want to call them differently, then you need an explicit binding. Everything is lucidly written.

In this example, since the Eloquent type-hinted the $user variable defined on the route matches the {user} segment in the route''s URI, Laravel will automatically inject the model instance that has an ID matching the corresponding value from the request URI. - jules_Nolan10 commented on July 9th 19 at 14:04
: Thank you - rupert_Weissnat79 commented on July 9th 19 at 14:07

Find more questions by tags Laravel