cybercog/laravel-ban

how can I ban only once?

joantp opened this issue · 2 comments

Is there a way to ban only if model is not already banned? So that I'd have just 0 or 1 ban record per user.
What method should I overwrite?

Thank you!

The easiest way - make a check in your controller if your user is already banned:

if ($user->isBanned()) {
    // throw an exception or return an error here
    // to stop executing controller

    abort(409);
}

$user->ban();

Ok. This is what I actually do. Thank you for your fast answer.