my link to edit
<a href="/dashboard/rejected/{{ $reject->id }}/edit" class="badge bg-danger">{{ $reject->status }}</a>
my route
Route::resource('/dashboard/rejected', RejectController::class);
my controller
public function edit(Reject $reject)
{
dd($reject);
return view('dashboard.reject.edit',[
'tittle' => 'Reject Stock',
'reject' => $reject
]);
}
$reject
on my controller is dont have data,
in my route list
GET|HEAD dashboard/rejected/{rejected}/edit rejected.edit›RejectController@edit
2
Answers
I advise you to use the function route() to refer to your path instead of hard typing it.
you can do:
then you should change the invoked function argument to be
finaly, your route name should be as following:
this is a more ‘elegent’ way to code, hope you find this useful.
When you use slash in resource , it will also be in route binding, so you should’n use it in resource , you can use
dashboard-rejected
in route and$dashboard_rejected
as param in controller , and you will get data.on a note :
put the noun in the plural in the route and the singular in the parameter,
example:
You also can customize route binding.