Download the PHP package illuminatech/db-safedelete without Composer

On this page you can find all versions of the php package illuminatech/db-safedelete. 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 db-safedelete

Laravel Eloquent Safe Delete


This extension provides "safe" deletion for the Eloquent model, which attempts to invoke force delete, and, if it fails - falls back to soft delete.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Usage

This extension provides "safe" deletion for the Eloquent model, which attempts to invoke force delete, and, if it fails - falls back to soft delete. It works on top of regular Laravel model soft deleting feature.

In case of usage of the relational database, which supports foreign keys, like MySQL, PostgreSQL etc., "soft" deletion is widely used for keeping foreign keys consistence. For example: if user performs a purchase at the online shop, information about this purchase should remain in the system for the future bookkeeping. The DDL for such data structure may look like the following one:

Thus, while set up a foreign key from 'purchase' to 'user', 'ON DELETE RESTRICT' mode is used. So on attempt to delete a user record, which have at least one purchase, a database error will occur. However, if user record have no external reference, it can be deleted.

This extension introduces Illuminatech\DbSafeDelete\SafeDeletes trait, which serves as an enhanced version of standard Illuminate\Database\Eloquent\SoftDeletes, allowing handing foreign key constraints and custom delete allowing logic. Being attached to the model Illuminatech\DbSafeDelete\SafeDeletes changes model's regular delete() method in the way it attempts to invoke force delete, and, if it fails - falls back to soft delete. For example:

Heads up! Make sure you do not attach both Illuminate\Database\Eloquent\SoftDeletes and Illuminatech\DbSafeDelete\SafeDeletes in the same model class. It will cause PHP naming conflict error since Illuminate\Database\Eloquent\SoftDeletes is already included into Illuminatech\DbSafeDelete\SafeDeletes.

Smart deletion

Usually "soft" deleting feature is used to prevent the database history loss, ensuring data, which has been in use and perhaps has a references or dependencies, is kept in the system. However, sometimes actual deleting is allowed for such data as well. For example: usually user account records should not be deleted but only marked as "trashed", however if you browse through users list and found accounts, which has been registered long ago, but don't have at least single log-in in the system, these records have no value for the history and can be removed from database to save a disk space.

You can make "soft" deletion to be "smart" and detect, if the record can be removed from the database or only marked as "trashed". This can be done via Illuminatech\DbSafeDelete\SafeDeletes::forceDeleteAllowed(). For example:

Manual delete flow control

Using Illuminatech\DbSafeDelete\SafeDeletes you can still manually "soft" delete or "force" delete a particular record, using following methods:

For example:


All versions of db-safedelete with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^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 illuminatech/db-safedelete contains the following files

Loading the files please wait ....