Git Product home page Git Product logo

laravel-userstamps's Introduction

Wildside/Userstamps

Provides an Eloquent trait to automatically maintain created_by and updated_by (and deleted_by when using SoftDeletes) on your models.

Requirements

  • This package requires PHP 5.6+
  • It works with Laravel 5.x (and may work with earlier versions too).

Installation

Require this package with composer

composer require wildside/userstamps

Migrate your Model's table to include a created_by and updated_by (and deleted_by if using SoftDeletes).

$table -> unsignedBigInteger('created_by') -> nullable() -> after('created_at');
$table -> unsignedBigInteger('updated_by') -> nullable() -> after('updated_at');

Load the trait in your Model.

use Wildside\Userstamps\Userstamps;

class Example extends Model {

    use Userstamps;
}

The following methods become available on your models to help retrieve the users creating, updating and deleting (if using SoftDeletes).

$model -> creator; // the user who created the model
$model -> editor; // the user who last updated the model
$model -> destroyer; // the user who deleted the model

If you want to manually set the created_by or updated_by properties on your model you can stop Userstamps being automatically maintained using the stopUserstamping method.

If you want to define the created_by, updated_by, or deleted_by column names, add the following class constants to your model(s).

const CREATED_BY = 'created_by';
const UPDATED_BY = 'updated_by';
const DELETED_BY = 'deleted_by';

License

This open-source software is licensed under the MIT license.

laravel-userstamps's People

Contributors

mattmcdonald-uk avatar mazyvan avatar romeromsk avatar tacone avatar tkayfun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.