Answer the question
In order to leave comments, you need to log in
How to properly implement destroy in Laravel?
Destroy does not work on the order editing page, it gives an error 500. Although when I delete a dish in the same order on the same page, everything is ok.
Delete button on the page
<button class="btn btn-danger float-sm-right js_order_destroy_btn" data-href="{{ route('cms_panel.orders.destroy',['order_id'=>$orders_row->id]) }}" type="button" style="margin: 0 10px;">Удалить</button>
$('.js_order_destroy_btn').click(function() {
if(confirm('Вы уверены, что хотите удалить заказ?')) location.href=$(this).data('href');
});
public function destroy(Request $request, $id)
{
$row = Orders::withTrashed()->findOrFail($id);
Orders::destroy($id);
return redirect()->route('cms_panel.orders.index', [])
->with('success','Deleted successfully');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question