Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 方法不允许使用guzzle_Php_Laravel 5_Guzzle6 - Fatal编程技术网

Php 方法不允许使用guzzle

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

我想使用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'] }}
 </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');


}