Reputation: 4668
I've having trouble passing off an object to my 'edit' view in Laravel 4. The URL is generated correctly "localhost/edit/1" however this is the returned error:
Some manadatory parameters are missing ("offer") to generate a URL for route "get edit/{offer}
My related routes.php snippet:
Route::get('edit/{offer}','OfferController@edit');
The OfferController@edit action:
public function edit(Offer $offer)
{
return View::make('edit',compact('offer'));
}
Just some extra detail, here's the snippet from the 'index' view that initiates the action:
<a href = "{{ action('OfferController@edit', $offer->id) }}">Edit</a>
I should also mention when I remove the Blade form in '/views/edit.blade.php' the view is created, including the header which specifies the $offer->id:
<h1>Edit Offer {{ $offer->id }}</h1>
What am I missing here?
Upvotes: 1
Views: 1269
Reputation: 1261
Your Edit function needs to be changed. You are passing id in link, but expects Instance of Offer
in edit
function. Assuming Offer
is an Eloquent
model,
public function edit($id)
{
$offer = Offer::find($id);
return View::make('edit',compact('offer'));
}
Hope this helps.
Upvotes: 1
Reputation: 87719
You need to pass an array to action()
:
<a href = "{{ action('OfferController@edit', array($offer->id)) }}">Edit</a>
Upvotes: 1