Database Eloquent ORM Deleting

Multiple ways of deleting:

use App\Models\Post;

/*
|--------------------------------------------------------------------------
| ELOQUENT ORM (Object Relational Model)
|--------------------------------------------------------------------------
*/

Route::get('/delete', function(){
    $post = Post::find(2);
    $post->delete();
});

Route::get('/delete2', function(){
    Post::destroy(3);
});

Route::get('/delete3', function(){
    Post::destroy([4,5]);
});

Route::get('/delete4', function(){
    Post::where('is_admin',0)->delete();
});

Leave a Reply

Your email address will not be published.