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

Implement method to disable deletion check #9

Open
ultrono opened this issue Jan 1, 2023 · 0 comments
Open

Implement method to disable deletion check #9

ultrono opened this issue Jan 1, 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 Jan 1, 2023

Implement method to disable deletion checks, i.e. so the result of isDeletable() is always true and any checks within isDeletable() are skipped. The API would look something along the lines of: the following.

A user may have a "deletable" restriction:

namespace App;

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

class User extends Model
{
  use RestrictsDeletion;
  
  public function isDeletable() : bool
  {
    return $this->orders()->doesntExist();
  }  
}

Assuming the user had orders, the following would fail and the model would not be deleted:

$user->delete();

The following would allow the deletable check to be skipped and the model would be deleted:

$user->withoutDeletableRestrictions()->delete()
@ultrono ultrono added good first issue Good for newcomers help wanted Extra attention is needed To do labels Jan 1, 2023
@ultrono ultrono changed the title Implemetn method to disable deletion checks Implement method to disable deletion check Jan 1, 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