PHPackages                             michaeljmeadows/created-by - 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. [Database &amp; ORM](/categories/database)
4. /
5. michaeljmeadows/created-by

ActiveLibrary[Database &amp; ORM](/categories/database)

michaeljmeadows/created-by
==========================

A simple trait to add User relationships to Eloquent models to track creation, updating, and deletion.

v2.1.0(2y ago)031MITPHPPHP ^8.0

Since Nov 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/michaeljmeadows/created-by)[ Packagist](https://packagist.org/packages/michaeljmeadows/created-by)[ RSS](/packages/michaeljmeadows-created-by/feed)WikiDiscussions main Synced 1mo ago

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

michaeljmeadows/created-by
==========================

[](#michaeljmeadowscreated-by)

A simple trait to add User relationships to Eloquent models to track creation, updating, and deletion.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require michaeljmeadows/created-by

```

Usage
-----

[](#usage)

Assuming you already have a `users` table, add the following fields to the model migration:

```
$table->foreignId('created_by')->nullable()->constrained('users');
$table->foreignId('updated_by')->nullable()->constrained('users');
$table->foreignId('deleted_by')->nullable()->constrained('users');
```

If you're using UUID or ULID ID fields, replace `foreignId` in the above with `foreignUuid` or `foreignUlid` fields accordingly

Once the fields are added to the model, you can simply include the trait in your model's definition:

```
