Muhammad Zaid Muhammad Zaid - 3 months ago 8
PHP Question

Laravel Destroy() is not removing any record from DB

Database Image

This is my controller's index method. When i run the code it does nothing.

public function index()
{
Customer::destroy(1);
return view('customer');
}


Model:

<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model {
protected $guarded = [];
public $timestamps=false;
}

Answer

Try using delete instead of destroy like this:

Customer::findOrFail(1)->delete();

or you can try directly from database using eloquent query builder:

Customer::where('id', 1)->delete();