PHPackages                             brainstud/has-identifier - 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. brainstud/has-identifier

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

brainstud/has-identifier
========================

Add a HasIdentifier to the model to take care of generating the identifier

v3.0.0(2mo ago)05.8k—6.2%1PHPPHP ^8.3

Since Jul 19Pushed 2mo agoCompare

[ Source](https://github.com/brainstudnl/has-identifier)[ Packagist](https://packagist.org/packages/brainstud/has-identifier)[ RSS](/packages/brainstud-has-identifier/feed)WikiDiscussions main Synced yesterday

READMEChangelog (4)Dependencies (6)Versions (16)Used By (1)

Has Identifier
==============

[](#has-identifier)

Automatically fill the `identifier` of your model by adding the `HasIdentifier` trait.

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

[](#installation)

Require the package

```
composer require brainstud/has-identifier
```

Usage
-----

[](#usage)

Add the `HasIdentifier` trait to your model.

```
/**
 * @property string $identifier
 */
class Item extends Model
{
    use HasIdentifier;

    protected $fillable = [
        'identifier'
    ];
}
```

The identifier will be filled on creation.

```
$model = Item::create();
echo $model->identifier;
```

### Use a different identifier attribute

[](#use-a-different-identifier-attribute)

The trait will use the `identifier` property of your model to generate an identifier to. You can overwrite the property the trait uses by setting the `identifierAttribute` on your model.

```
/**
 * @property string $identifier
 */
class Item extends Model
{
    use HasIdentifier;

    protected string $identifierAttribute = 'uuid';

    protected $fillable = [
        'uuid'
    ];
}
```

### Find by identifier

[](#find-by-identifier)

There are different ways to get the model by identifier.

```
// Find method
$model = Item::findByIdentifier($uuid);
$model = Item::findOrFailByIdentifier($uuid);

// Scope
$model = Item::identifiedBy($uuid)->first();
```

Test
----

[](#test)

You can run the tests with

```
composer test
```

License
-------

[](#license)

has-identifier is open-sourced software licensed under the [MIT License](LICENSE)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~144 days

Recently: every ~256 days

Total

13

Last Release

78d ago

Major Versions

v1.0.3 → v2.0.02022-02-10

v2.1.0 → v3.0.02026-04-16

PHP version history (4 changes)v1.0.0PHP ^8.0

v1.0.3PHP ^7.4 || ^8.0

v2.0.5PHP ^7.4 || ^8.2

v3.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/59a4113e79a9d7d16cf8857d4f256eabf9cd2a546b692a9ffb02b2ab86799567?d=identicon)[Diondb](/maintainers/Diondb)

![](https://www.gravatar.com/avatar/dcdd9cd8db3f43b6b6c140ff30840863339e17180bd3ea6745c9b151136610d7?d=identicon)[brdv](/maintainers/brdv)

---

Top Contributors

[![brdv](https://avatars.githubusercontent.com/u/44579145?v=4)](https://github.com/brdv "brdv (8 commits)")[![Diondb](https://avatars.githubusercontent.com/u/84917298?v=4)](https://github.com/Diondb "Diondb (5 commits)")[![Reinand](https://avatars.githubusercontent.com/u/133855289?v=4)](https://github.com/Reinand "Reinand (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brainstud-has-identifier/health.svg)

```
[![Health](https://phpackages.com/badges/brainstud-has-identifier/health.svg)](https://phpackages.com/packages/brainstud-has-identifier)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[crumbls/layup

A visual page builder plugin for Filament 5 — Divi-style grid layouts with extensible widgets.

592.7k2](/packages/crumbls-layup)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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