Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NoneDeletableModel trait to package #12

Open
ultrono opened this issue Apr 9, 2023 · 0 comments
Open

Add NoneDeletableModel trait to package #12

ultrono opened this issue Apr 9, 2023 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed To do

Comments

@ultrono
Copy link
Contributor

ultrono commented Apr 9, 2023

Ads a simple trait called NoneDeletableModel to the package. The trait could then be used in Eloquent models to deny all deletion attempts:

declare(strict_types=1);

namespace F9Web\LaravelDeletable\Traits\Traits;

use F9Web\LaravelDeletable\Traits\RestrictsDeletion;

trait NoneDeletableModel
{
    use RestrictsDeletion;

    public function isDeletable() : bool
    {
        return false;
    }
}

To prevent all deletion requests for a model:

declare(strict_types=1);

namespace App\Models;

use F9Web\LaravelDeletable\Traits\NoneDeletableModel;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
   use NoneDeletableModel;
}

Now, orders cannot be deleted.

@ultrono ultrono added good first issue Good for newcomers help wanted Extra attention is needed To do labels Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed To do
Projects
None yet
Development

No branches or pull requests

1 participant