i want delete data by id using guzzle for http request but method not allowed
view file
<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>
Route file
Route::post('/delete/{id}', 'adminController@deleteBidang');
Controller File
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');
}
what the solution ?
You wrongly taking deleting id, use like this.
$result = $client->delete("http://localhost:8000/api/admin/kategori/bidang/{$request->id}");
First of all you should use the laravel url routing in your blade template
<a href="{{ url('/delete/'.$value['id']) }}" style="float: right;" data-method="delete">Delete</a>
and your controller should look like this. you did not recive the $id in your function. Also the url did not seem right. to my knowlage this should work
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');
}