PHPackages                             constant-null/eloquent-changed-by-user - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. constant-null/eloquent-changed-by-user

ActiveUtility[Utility &amp; Helpers](/categories/utility)

constant-null/eloquent-changed-by-user
======================================

This simple trait written for eloquent allows you to automaticly write down id of last user changed the database record.

v0.1.1(10y ago)126MITPHPPHP &gt;=5.4.0

Since Dec 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/constant-null/eloquent-changed-by-user)[ Packagist](https://packagist.org/packages/constant-null/eloquent-changed-by-user)[ RSS](/packages/constant-null-eloquent-changed-by-user/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Saving last user changed database record for Eloquent models (Laravel 5)
========================================================================

[](#saving-last-user-changed-database-record-for-eloquent-models-laravel-5)

> Please be aware that this trait uses `Auth` facade and expects it to implement `Illuminate\Contracts\Auth\Guard` contract

How it works
------------

[](#how-it-works)

Quite simple actually, just before saving row to database, this trait gets id of current user using `Auth::user()->id` (thats why requirements above exists) and write it to specified database field (for more specifics read the **Installation and configuration** section)

Installation and configuration
------------------------------

[](#installation-and-configuration)

This trait can be installed via [composer](http://getcomposer.org/). Just add following to your `composer.json` file:

```
{
    "require": {
        "constant-null/eloquent-changed-by": "~0.1"
    }
}
```

and then run:

```
$ composer update

```

To start using this trait you need to import it to Eloquent model

```
