I\'m new to Laravel. I have created a model, a resource controller, and a route for one of my tables, I have modified the model class to use a particular table name, but the
I also run into this problem. Laravel will follow the convention for naming the parameter.
For example your model is
AwesomeCategory
Then auto-generated edit method in AwesomeCategoryController will look like this
public function edit(AwesomeCategory $awesomeCategory) // This will not load any attributes
Change to
public function edit(AwesomeCategory $awesomecategory) // This will be automatically loaded with all attributes
The issue comes in the resource routing. Replace your routing as
Route::resource('category', 'CategoryController');
Here the route name must exactly match with the controller name. That was the problem.
There is a naming convention on Route Model binding.
Try to change the action call to this:
public function show(Tree $category)
{
var_dump($category);
}
Update: I looked in the source and you can also change the parameters name in resource Route declaration:
Route::resource('categories', 'CategoryController', ['parameters'=>['categories'=>'tree']]);
And use the $tree variable in action call
public function show(Tree $tree)