这是我的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";
}