Download the PHP package f9webltd/laravel-deletable without Composer

On this page you can find all versions of the php package f9webltd/laravel-deletable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-deletable

Packagist Version run-tests-laravel-8 StyleCI Status Packagist License [PHP ^8.2]()

Laravel Deletable

Gracefully handle deletion restrictions on your Eloquent models, as featured on Laravel News

Requirements

For older versions of PHP / Laravel use version 1.0.6

Installation

The package will automatically register itself.

Optionally publish the configuration file by running: php artisan vendor:publish and selecting the appropriate package.

Documentation

Usage

Within an Eloquent model use the RestrictsDeletion trait:

The trait overrides calls to Eloquent's delete() method.

Implement the isDeletable() method within the model in question.

This method should return true to allow deletion and false to deny deletion:

The above denies deletion of users with orders.

None deletable models throw an exception when the isDeletable() method returns false:

Eloquent Base Model

As the default isDeletable() method returns true, a base Eloquent model can be optionally defined from which all models extend. Each model can then optionally implement the isDeletable() method as needed.

Customising Messages

The default exception message is defined within the config f9web-laravel-deletable.messages.default and is simply The model cannot be deleted.

By setting f9web-laravel-deletable.messages.default to null a more detailed message is automatically generated i.e. Restricted deletion: App\User - 1 is not deletable.

Custom messages can be set within the isDeletable() method:

The denyDeletionReason() method can be used to specify the exception message.

In the above case, the exception message is Users with f9web.co.uk company email addresses cannot be deleted.

Multiple Checks

Multiple checks can be performed within isDeletable() if necessary, each of which returning a different exception message:

Contribution

Any ideas are welcome. Feel free to submit any issues or pull requests.

Testing

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-deletable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/config Version ^10.0|^11.0
illuminate/container Version ^10.0|^11.0
illuminate/contracts Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package f9webltd/laravel-deletable contains the following files

Loading the files please wait ....