Laravel Eloquent: Deleting Models

$flight = App\Flight::find(1);

$flight->delete();

Deleting An Existing Model By Key

App\Flight::destroy(1);

App\Flight::destroy(1, 2, 3);

App\Flight::destroy([1, 2, 3]);

App\Flight::destroy(collect([1, 2, 3]));

Deleting Models By Query

$deletedRows = App\Flight::where('active', 0)->delete();

Soft Deleting

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Flight extends Model
{
    use SoftDeletes;

    /**
     * The attributes that should be mutated to dates.
     *
     * @var array
     */
    protected $dates = ['deleted_at'];
}
Schema::table('flights', function (Blueprint $table) {
    $table->softDeletes();
});
If ($flight->trashed()) {
    //
}

Querying Soft Deleted Models

Laravel Eloquent: Deleting Models — Structure map

Clickable & Draggable!

Laravel Eloquent: Deleting Models — Related pages: