Home · Projects · Templates · Articles · Speaking · Uses · Contact · FAQ · Community · AI Tools · Developer Tools · Items

Laravel Soft Deletes Tutorial: Safely Removing Records

Learn how Laravel soft deletes work — mark records as deleted without losing data, restore them, and query trashed records.

Permanently deleting data is risky — what if a user accidentally deletes an important record? Laravel's soft delete feature marks records as deleted without actually removing them from the database, so they can be restored later. How Soft Deletes Work Instead of removing a row, Laravel sets a deleted at timestamp on it. Any record with a non null deleted at is automatically excluded from normal queries — but the data still exists. Step 1: Add the deleted at Column php artisan make:migration add soft deletes to products table table=products use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; public function up(): void { Schema::table('products', function (Blueprint $table) { $table >softDeletes(); }); } public function down(): void { Schema::table('products', function (Blueprint $table) { $table >dropSoftDeletes(); }); } php artisan migrate Step 2: Ad...

Home · Projects · Articles · Developer tools · Contact