tabuna / breadcrumbs

Laravel Breadcrumbs - An easy way to add breadcrumbs to your @Laravel app.
https://github.com/tabuna/breadcrumbs
MIT License
339 stars 20 forks source link

Argument 2 passed to {closure}() must be an instance of #10

Open akshay13aac opened 4 years ago

akshay13aac commented 4 years ago

closure://function (\Tabuna\Breadcrumbs\Trail $trail, \App\Models\Backend\Chamber $chamber) { $trail->parent('admin.chambers.index') ->push(__('Editing :chamber', ['chamber' => $chamber->id]), route('admin.chambers.edit', $chamber)); }:2

DeBelserArne commented 3 years ago

Have u imported use Tabuna\Breadcrumbs\Trail; ?

octoquad commented 3 years ago

I had this problem as well. For the route URI you need to set the parameter to match the second argument of the breadcrumbs function:

Route::get('admin/chambers/{chamber}', ...)

instead of

Route::get('admin/chambers/{id}', ....)

This will inject the value (in this case, the ID of the record to load) into the Chamber class and instantiate a new model (route model binding).

The full error is

Argument 2 passed to {closure}() must be an instance of App\Models\Chamber, string given