I am getting totally frustrated now...
Trying to use an edit method within a controller. All the other controllers work fine, but here I might have missed something and could not find.
Error:
Missing required parameters for [Route: blocked.edit] [URI:
remittance/blocked/{blocked}/edit]. (View:
/var/www/xxxxxxxx/resources/views/layouts/app.blade.php) (View:
/var/www/xxxxxxxx/resources/views/layouts/app.blade.php)
Here is my controller method:
public function edit($id)
{
$blocked = $this->model->find($id);
return view('remittance::edit', compact('blocked'));
}
Route to this method:
remittance/blocked/{blocked}/edit | blocked.edit | Modules\Remittance\Http\Controllers\RemittanceController@edit
Route:
Route::resource('remittance/blocked', 'RemittanceController', [
'except' => ['show']
]);
I am calling this method from DataTables, whenever I click edit I am directed to url:
http://localhost/remittance/blocked/xxxx/edit
Snippet from DataTables class where it is rendered:
addColumn('action', function ($query) {
return view('partials.actions.delete', [
'actions' => ['edit'],
'route' => $this->model,
'object' => $query
]);
})
Which is correct for the routes. I checked other similar topics to this one, but all of them were caused because of missing {parameter}.
use this maybe help you
public function edit(Blocked $blocked)
{
$blocked = $blocked;
return view('remittance::edit', compact('blocked'));
}
if not work then let me know
The name of the parameter in the route should be same with the parameter in the method. So if, the uri markup is remittance/blocked/{blocked}/edit
, it must be public function edit($blocked){...
Looks like it was a problem with breadcrumbs. I have registered a route there and did not pass the required parameters. Totally forgot, that layout.app was loading breadcrumbs.
Now:
Breadcrumbs::register('blocked.edit', function ($breadcrumbs, $blocked) {
$breadcrumbs->parent('blocked.index');
$breadcrumbs->push(trans('remittance::titles.edit'), route('blocked.edit', compact('blocked')));
});
Was before:
Breadcrumbs::register('blocked.edit', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('remittance::titles.edit'), route('blocked.edit'));
});
Thank You everyone for help :)