当我尝试在POST路由中使用Auth中间件时,在RouteCollection.php中获取此异常MethodNotAllowedHttpException

时间:2016-01-11 23:19:23

标签: php laravel laravel-routing laravel-5.2 laravel-blade

这是我的Blade语法:

<form action="{{URL::to('favorite')}}" method="POST" accept-charset="utf-8">
    <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
    <input type="hidden" name="id_medicine" value="{{$medicine->id}}">
    <button type="submit" class="btn btn-primary">Add To My List</button>
</form>

然后路线:

 Route::post('/favorite', ['as' => 'favorite', 'middleware' => 'auth', 'uses' => 'MedicineController@makeFavorite'] );

控制器方法:

public function makeFavorite(Request $request)
    {
       return "success";
    }

0 个答案:

没有答案