delete in laravel eloquent code example
Example 1: laravel delete where
DB::table('users')->where('id', $id)->delete();
Example 2: laravel fillable
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
Example 3: laravel create or update
$flight = App\Models\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
Example 4: laravel eloquent remove from db
$res=User::where('id',$id)->delete();
Example 5: laravel delete
DB::table('users')->where('votes', '>', 100)->delete();
Example 6: Laravel Delete
Flight::destroy(1);
Flight::destroy(1, 2, 3);
Flight::destroy([1, 2, 3]);
Flight::destroy(collect([1, 2, 3]));