-
add
"repositories": [ { "type": "vcs", "url": "git@github.com:wilzokch/laravel-custom-soft-delete.git" } ],
to your composer.json.
-
run the
composer require
command from your terminal:composer require wilzokch/laravel-custom-soft-delete:dev-master
-
add the Wilzokch\LaravelCustomSoftDelete\SoftDeletes trait to the model:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Wilzokch\LaravelCustomSoftDelete\SoftDeletes; class Flight extends Model { use SoftDeletes; }
-
add soft delete columns to your migration
use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; Schema::table('flights', function (Blueprint $table) { $table->tinyInteger('is_deleted')->default(false)->index(); $table->timestamp('deleted_at')->nullable(); }); Schema::table('flights', function (Blueprint $table) { $table->dropColumn('is_deleted'); $table->dropColumn('deleted_at'); });
wilzokch/laravel-custom-soft-delete
Laravel package that use is_deleted flag for soft delete & retain deleted_at to keep track date of deletion
PHP