Deleting Models: Querying Soft Deleted Models

Including Soft Deleted Models

$flights = App\Flight::withTrashed()
                ->where('account_id', 1)
                ->get();
$flight->history()->withTrashed()->get();

Retrieving Only Soft Deleted Models

$flights = App\Flight::onlyTrashed()
                ->where('airline_id', 1)
                ->get();

Restoring Soft Deleted Models

$flight->restore();
App\Flight::withTrashed()
        ->where('airline_id', 1)
        ->restore();
$flight->history()->restore();

Permanently Deleting Models

// Force deleting a single model instance...
$flight->forceDelete();

// Force deleting all related models...
$flight->history()->forceDelete();

Deleting Models: Querying Soft Deleted Models — Structure map

Clickable & Draggable!

Deleting Models: Querying Soft Deleted Models — Related pages: