Reputation: 61
I am having trouble with routing in Laravel 5.4. I am trying to display a simple edit form for a company.
The error I'm getting is
web.php:
$this->get('company/edit/{company}','SuperAdmin\CompanyController@showEditForm')->name('company.edit');
$this->post('company/edit', 'SuperAdmin\CompanyController@edit');
How I build link to the route:
<a href="{{route('company.edit', ['company' => $company->id])}}" class="btn btn-success">Edit</a>
In the controller:
public function showEditForm()
{
return view('super.company.edit');
}
SOLVED: Dear god, I've forgot to add the parameter to the route()
method in the view where I render the form. Thanks everyone.
Upvotes: 0
Views: 796
Reputation: 138
First of all you can debug the id like dd($company->id)
to make sure you are really getting the desired id, because if its null
it won't work.
It sounds silly, but it happens..
Upvotes: 2
Reputation: 2010
You do not need to define the key for the route variable just pass it as a second argument in the route
function. Laravel will automatically resolve the parameter in the order.
Like:
route('company.edit', $company->id);
Hope it would help.
Upvotes: 0