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;
}
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();
You can also write your code like this
public function getDeleteTag($id)
{
DB::table('tags')
->where('id','=',$id)
->delete();
return Response::json(['message' => 'Tag has been deleted successfully!']);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.