maryamfadhillah / soft-delete-extra
Laravel package for extended soft delete with deleted_by
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/maryamfadhillah/soft-delete-extra
Requires
- php: ^8.0
- illuminate/support: ^10.0
README
A simple Laravel package that override the default SoftDeletes functionality by adding custom fields such as is_deleted and deleted_by without keeping deleted_at from Laravel's native implementation.
Features
- Automatically fills:
is_deleted→ mark row as deleted (1 = deleted, 0 = active).deleted_by→ stores the user ID who deleted the record.
- Can be reused across multiple models using a single trait.
Requirement
- PHP 8.0
- Laravel 10
Installation
- Install via Composer:
composer require maryamfadhillah/soft-delete-extra
- Add the trait to your Model
use Illuminate\Database\Eloquent\Model;
use App\Traits\SoftDeleteExtra;
class Product extends Model
{
use SoftDeleteExtra;
protected $fillable = [
'name',
'deleted_by',
'is_deleted',
// ...
];
}
Database Requirement
Make sure your table contains the following columns in addition to your normal fields:
ALTER TABLE products
ADD deleted_by INT NULL,
ADD is_deleted TINYINT DEFAULT 0;
Usage
It's completely the same as Laravel's Soft Delete.