auto-injected Laravel model has no attributes

前端 未结 3 750
囚心锁ツ
囚心锁ツ 2021-01-18 13:30

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

3条回答
  •  忘掉有多难
    2021-01-18 14:03

    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)
    

提交回复
热议问题