我正在尝试更新列值以批准服务(将值从0更改为1) 而且我收到了一个错误:
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException 没有消息
这是控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Session;
use App\Service;
class ServiceController extends Controller{
public function approuver($id){
Service::where([
'id' => $id,
])->update(array('flag'=>1));
$request->session()->flash('notif','Mise à jour reussi!');
return back();
}
}
这是路线:
Route::post('/Services/approuver/{id}', 'ServiceController@approuver');
这是刀片文件:
<div id="modal1{{$service->id}}" class="modal">
<div class="modal-content">
<p>Voulez vous vraiment approuver ce service ?</p>
<div class="row">
<form class="col s12" method="post"
action="/Services/approuver/{{$service->id}}">
{{ csrf_field() }}
@method('PUT')
<span> <input type="submit" class="btn purple hoverable waves
effect" value="Oui"></span>
<span> <a href="#" class="btn red hoverable waves effect modal-
action modal-close" id="Non"> Non</a></span>
</form>
</div>
</div>
答案 0 :(得分:0)
您正在发出PUT请求,但在您的路线中您使用了POST方法 在你的路线中这样做
Route::put('/Services/approuver/{id}', 'ServiceController@approuver');
答案 1 :(得分:0)
您的路线定义为POST
,但您的表单有@method('PUT')
。您必须决定要使用哪一个。
答案 2 :(得分:0)
您应该删除@method('PUT')
或更改此定义的路线。
Route::put('/Services/approuver/{id}', 'ServiceController@approuver');