PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 22 All time: 11,259 This week: 71Up
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: 38 packages by
Country: Egypt Egypt
Age: 31
All time rank: 257626 in Egypt Egypt
Week rank: 195 Up5 in Egypt Egypt Up
Innovation award
Innovation award
Nominee: 22x

Documentation

<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 (5)  
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 (5)  /  src  
File Role Description
  Plain text file Auditable.php Class Class source
  Plain text file AuditsServiceProvider.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:22
This week:0
All time:11,259
This week:71Up