Laravel Auditable: Track the users that make changes to model objects

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2021-04-29 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 15 All time: 10,383 This week: 259Up
Version License PHP version Categories
laravel-auditable 1.0MIT/X Consortium ...5PHP 5, Databases, Libraries, Design P...
Description Author

This package can be used to track the users that make changes to model objects in Laravel applications.

It provides a trait that are able to detect when an object is created, updated or deleted, and record the application user that requested the changes and the time when those changes happened.

Tracking the delete actions is only possible when another trait that supports soft-deletes is used.

Picture of Moamen Eltouny
  Performance   Level  
Name: Moamen Eltouny <contact>
Classes: 32 packages by
Country: Egypt Egypt
Innovation award
Innovation award
Nominee: 17x

Details

<p align="center"><a href="https://pharaonic.io" target="_blank"><img src="https://raw.githubusercontent.com/Pharaonic/logos/main/auditable.jpg" width="470"></a></p>

<p align="center"> <a href="https://github.com/Pharaonic/laravel-auditable" target="_blank"><img src="http://img.shields.io/badge/source-pharaonic/laravel--auditable-blue.svg?style=flat-square" alt="Source"></a> <a href="https://packagist.org/packages/pharaonic/laravel-auditable" target="_blank"><img src="https://img.shields.io/packagist/v/pharaonic/laravel-auditable?style=flat-square" alt="Packagist Version"></a><br> <a href="https://laravel.com" target="_blank"><img src="https://img.shields.io/badge/Laravel->=6.0-red.svg?style=flat-square" alt="Laravel"></a> <img src="https://img.shields.io/packagist/dt/pharaonic/laravel-auditable?style=flat-square" alt="Packagist Downloads"> <img src="http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="Source"> </p>

<h1 align="center">Laravel Auditable</h1>

Install

Install the latest version using Composer:

$ composer require pharaonic/laravel-auditable

<br>

Usage Steps

<a name="CS"></a>

Create auditable columns on the table

Just add one of this lines to your Migration file.
// created_by, created_at
// updated_by, updated_at
$table->auditable();

// created_by, created_at
// updated_by, updated_at
// deleted_by, deleted_at
$table->auditableWithSoftDeletes();

<br>

<a name="US"></a>

Auditable with the model

Auditable without SoftDeletes
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Pharaonic\Laravel\Audits\Auditable;

class Article extends Model
{
    use Auditable;
}

Auditable with SoftDeletes
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Pharaonic\Laravel\Audits\Auditable;

class Article extends Model
{
    use Auditable;
    use SoftDeletes;
}

<br>

<a name="HTU"></a>

How To Use

// Creating
$article = Article::create(['title' => 'Moamen Eltouny']);
echo $article->created_at->isoFormat('LLLL');
echo $article->created_by->name;

// Updating
$article = Article::first();
echo $article->updated_at->isoFormat('LLLL');
echo $article->updated_by->name;

// Deleting (ONLY WITH SoftDeletes)
$article->delete();
$article = Article::withTrashed()->first();
echo $article->deleted_at->isoFormat('LLLL');
echo $article->deleted_at->name;

<br><br>

License

MIT license

  Files folder image Files  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  src  
File Role Description
  Plain text file Auditable.php Class Class source
  Plain text file AuditsServiceProvider.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:15
This week:0
All time:10,383
This week:259Up
For more information send a message to info at phpclasses dot org.