PHPackages                             rulr/laravel-authored - 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. rulr/laravel-authored

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

rulr/laravel-authored
=====================

A Laravel package that adds created\_by and last\_updated\_by attributes to Eloquent models.

v1.2.1(1y ago)41.9kMITPHPPHP ^8.1

Since Mar 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rulr-dev/laravel-authored)[ Packagist](https://packagist.org/packages/rulr/laravel-authored)[ RSS](/packages/rulr-laravel-authored/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (5)Used By (0)

Laravel Authored
================

[](#laravel-authored)

Introduction
------------

[](#introduction)

`rulr/laravel-authored` is a Laravel package that automatically assigns `created_by` and `updated_by` user IDs to Eloquent models. This helps track which user created and last updated a model, improving data auditing and accountability.

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

[](#installation)

You can install the package via Composer:

```
composer require rulr/laravel-authored
```

Usage
-----

[](#usage)

### 1. Apply the `HasAuthor` Trait

[](#1-apply-the-hasauthor-trait)

To enable automatic tracking, add the `HasAuthor` trait to your Eloquent models:

```
use Illuminate\Database\Eloquent\Model;
use Rulr\Authored\Traits\HasAuthor;

class Post extends Model
{
    use HasAuthor;
}
```

### 2. Use the `authored` Macro in Migrations

[](#2-use-the-authored-macro-in-migrations)

Instead of manually defining `created_by` and `updated_by`, you can use the provided macro when defining your schema:

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->authored(); // Automatically adds created_by and updated_by fields
    $table->timestamps();
});
```

### 3. Configuration

[](#3-configuration)

By default, this package uses `created_by` and `updated_by` columns. You can **customize** these field names by publishing and modifying the config file.

#### **Publishing the Config File**

[](#publishing-the-config-file)

```
php artisan vendor:publish --provider="Rulr\Authored\AuthoredServiceProvider" --tag=config
```

This will create a file at `config/authored.php`, where you can modify the column names:

```
return [
    'created_by' => 'created_by',
    'updated_by' => 'updated_by',
];
```

Now, when using `$table->authored();`, it will use the specified field names.

### 4. Automatically Set User IDs

[](#4-automatically-set-user-ids)

When a user creates or updates a model, Laravel will automatically assign their ID:

```
$post = Post::create(['title' => 'First Post']);
$post->update(['title' => 'Updated Title']);

// Outputs the user ID who created the post
echo $post->created_by;

// Outputs the user ID who last updated the post
echo $post->updated_by;
```

Testing
-------

[](#testing)

This package includes PHPUnit tests using Orchestra Testbench. The tests create tables dynamically without requiring migrations. To run tests, use:

```
vendor/bin/phpunit
```

License
-------

[](#license)

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

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Total

4

Last Release

407d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90d2f3f97c8a70c3cd012f35a173332932f1913429a90a9ee5a7a20a5e1b1fe7?d=identicon)[raffi](/maintainers/raffi)

---

Top Contributors

[![Raffi-001](https://avatars.githubusercontent.com/u/1436901?v=4)](https://github.com/Raffi-001 "Raffi-001 (6 commits)")

---

Tags

laraveleloquenttrackingcreated\_byupdated\_byauthorship

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rulr-laravel-authored/health.svg)

```
[![Health](https://phpackages.com/badges/rulr-laravel-authored/health.svg)](https://phpackages.com/packages/rulr-laravel-authored)
```

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M88](/packages/mongodb-laravel-mongodb)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.5k12.4M294](/packages/spatie-laravel-sluggable)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
