Download the PHP package esign/laravel-database-auditing without Composer

On this page you can find all versions of the php package esign/laravel-database-auditing. 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-database-auditing

Track database changes in Laravel using database triggers.

Latest Version on Packagist Total Downloads GitHub Actions

This package allows you to track changes in your database using database triggers. Currently only MySQL is supported.

Note This package is designed to track database changes that occur outside of Laravel. However, for changes originating within a Laravel application, other solutions like owen-it/laravel-auditing may better suit your requirements.

Installation

You can install the package via composer:

The package will automatically register a service provider.

This package comes with a migration to store your database changes. You can publish the migration file:

Running this command will publish the following migration:

Next up, you can optionally publish the configuration file:

The config file will be published as config/database-auditing.php with the following contents:

Usage

Creating database triggers

To track database changes, use the php artisan make:audit-trigger command. This will generate a migration file with the necessary trigger configuration:

By default, a trigger name will be automatically assigned based on the provided input. However, you can specify a different name by passing it as the first argument:

Retrieving tracked changes

After running the trigger migration, any modifications made to the associated table will be automatically monitored and stored in the audits table.

Here is a representation of how audits are stored in the audits table based on different trigger events: id event auditable_type auditable_id old_data new_data
1 insert post 1 NULL {"title": "My Post"}
2 update post 1 {"title": "My Post"} {"title": "My Updated Post"}
3 delete post 1 {"title": "My Post"} NULL

To retrieve the recorded changes in your Laravel project, you can utilize the Esign\DatabaseAuditing\Models\Audit model provided by the package. Here's an example:

To determine if any data changes occurred in an audit, you can utilize the hasDataChanges() method available on the Audit model. Here's how you can use it:

The hasDataChanges() method returns a boolean value indicating whether any changes were made. If you pass a specific attribute name as an argument, it will check for changes in that particular attribute only.

To retrieve audits based on specific trigger events, you can use the event() scope provided by the Audit model. Here's an example:

Tracking changes in Eloquent models

To track changes related to your Eloquent model, apply the Esign\DatabaseAuditing\Concerns\HasAudits trait to the respective model. For instance:

This will enable an audits relationship on the model, allowing you to access the tracked changes. For example:

Feel free to explore the Esign\DatabaseAuditing\Models\Audit model for more functionality related to tracking and retrieving changes.

Testing

License

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


All versions of laravel-database-auditing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
esign/laravel-database-trigger Version ^1.5.0
illuminate/database Version ^12.0
illuminate/support Version ^12.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 esign/laravel-database-auditing contains the following files

Loading the files please wait ....