问题
This is my html blade code
{{ Form::open(array('route' => 'restaurants.update', 'class' => 'mainInformationContrainer')) }}
<ul>
<li>
<label>Website</label>
<div class="oneInfo">
<input type="text" value="{{$restaurant->website}}" />
</div>
</li>
<li>
<input type="submit" value="Save Changes"/>
<input type="button" value="Cancle" class="cancelButton"/>
</li>
</ul>
{{ Form::close() }}
But the url for the form is : public/restaurants/%7Brestaurants%7D
Thought I already have the route:
Route::resource('restaurants', 'RestaurantsController');
回答1:
As @Mark Baker said %7B and %7D are { and } respectively , laravel expect you to pass the id of the resource you want to update.
If you see the board with the action you will notice that you have to pass the resource id.
PUT/PATCH /resource/{resource} update resource.update
You can use the route
helper function to fix it.
{{ Form::open(array('route' => route('restaurants.update', $restaurant->id), 'class' => 'mainInformationContrainer')) }}
来源:https://stackoverflow.com/questions/24476541/update-route-generates-incorrect-url