Php 方法不允许使用guzzle
我想使用guzzle为http请求按id删除数据,但不允许使用此方法 查看文件Php 方法不允许使用guzzle,php,laravel-5,guzzle6,Php,Laravel 5,Guzzle6,我想使用guzzle为http请求按id删除数据,但不允许使用此方法 查看文件 <div class="panel-heading clickable"> <h3 class="panel-title"> <a href="/delete/{{$value['id']}}" style="float: right;" data-method="delete">Delete</a> {{ $value['nama'] }} &l
<div class="panel-heading clickable">
<h3 class="panel-title">
<a href="/delete/{{$value['id']}}" style="float: right;" data-method="delete">Delete</a>
{{ $value['nama'] }}
</h3>
</div>
控制器文件
public function deleteBidang(Request $request){
$client = new Client([
'base_uri' => 'http://localhost:8000/api',
'http_errors' => false,
'debug' => true
]);
$result = $client->delete('http://localhost:8000/api/admin/kategori/bidang/{id}');
return redirect('admin/cattegory');
}
解决方案是什么?您错误地获取了删除id,请这样使用
$result = $client->delete("http://localhost:8000/api/admin/kategori/bidang/{$request->id}");
首先,您应该在刀片模板中使用laravel url路由
<a href="{{ url('/delete/'.$value['id']) }}" style="float: right;" data-method="delete">Delete</a>
您甚至还没有发布原始错误。请下次尊重其他用户并更新您的问题。
<a href="{{ url('/delete/'.$value['id']) }}" style="float: right;" data-method="delete">Delete</a>
public function deleteBidang(Request $request, $id){
$client = new Client([
'base_uri' => 'http://localhost:8000/api',
'http_errors' => false,
'debug' => true
]);
$result = $client->delete('http://localhost:8000/api/admin/kategori/bidang/'.$id);
return redirect('admin/cattegory');
}