tkachikov/laravel-withtrashed

Trait for set magic method withTrashed for models with SoftDelete

1.0.2 2023-06-07 14:01 UTC

This package is auto-updated.

Last update: 2024-05-07 16:18:29 UTC


README

License: MIT

Trait for set magic method withTrashed for models with SoftDelete

Usage

use Tkachikov\LaravelWithtrashed\WithTrsashed;

class User {
    use WithTrashed;
    
    public function posts()
    {
        return $this->hasMany(Post::class);
    }
}

$posts            = $user->posts;            // default
$postsWithTrashed = $user->postsWithTrashed; // using trait

$postsBuilder            = $user->posts();            //default
$postsBuilderWithTrashed = $user->postsWithTrashed(); // using trait

$userPosts            = User::with('posts')->first();            // default
$userPostsWithTrashed = User::with('postsWithTrashed')->first(); // using trait

License

This package is open-sourced software licensed under the MIT license.