Update route generates incorrect url

荒凉一梦 提交于 2019-12-25 03:58:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!