Laravel Deletable Pack

Laravel Deletable is a package that imposes deletion restrictions on your Eloquent models. package RestrictsDeletionprovides a feature for the models you want to control deleting:

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->isEmpty();

A model isDeletable()When the method returns falseconsists of a model exception:

namespace App\Controllers;use F9Web\LaravelDeletable\Exceptions\NoneDeletableModel;
use App\User;
class UsersController
public function destroy(User $user): bool
try {
} catch (NoneDeletableModel $e) {

You can learn more about this package, get all the installation instructions and review the source code on GitHub at f9webltd/laravel-deletable.


KARABAY A, 2020 . Laravel Deletable Package,

(Accessed July 18, 2020).

  Share this post

Comments (0)


Sign up for the email newsletter to be the first to know about my blog posts