Skip to content

Laravel package that use is_deleted flag for soft delete & retain deleted_at to keep track date of deletion

Notifications You must be signed in to change notification settings

wilzokch/laravel-custom-soft-delete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Custom Soft Delete ( Laravel 5 Package )

php 5.5+ author

Installation

  1. add

     "repositories": [
         {
             "type": "vcs",
             "url":  "[email protected]:wilzokch/laravel-custom-soft-delete.git"
         }
     ],
    

    to your composer.json.

  2. run the composer require command from your terminal:

     composer require wilzokch/laravel-custom-soft-delete:dev-master
    
  3. 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;
    }
    
  4. 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');
     });
    

About

Laravel package that use is_deleted flag for soft delete & retain deleted_at to keep track date of deletion

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages