PHPackages                             touhidurabir/laravel-model-uuid - 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. touhidurabir/laravel-model-uuid

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

touhidurabir/laravel-model-uuid
===============================

A laravel package to attach uuid to model classes

1.1.1(4y ago)102972MITPHP

Since Aug 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/touhidurabir/laravel-model-uuid)[ Packagist](https://packagist.org/packages/touhidurabir/laravel-model-uuid)[ RSS](/packages/touhidurabir-laravel-model-uuid/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (7)Versions (8)Used By (2)

Laravel Model UUID
==================

[](#laravel-model-uuid)

A simple package to generate model uuid for laravel models

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

[](#installation)

Require the package using composer:

```
composer require touhidurabir/laravel-model-uuid
```

To publish the config file:

```
php artisan vendor:publish --provider="Touhidurabir\ModelUuid\ModelUuidServiceProvider" --tag=config
```

Usage
-----

[](#usage)

Use the trait **HasUuid** in model where uuid needed to attach

```
use Touhidurabir\ModelUuid\HasUuid;
use Illuminate\Database\Eloquent\Model;

class User extends Model {

    use HasUuid;
}
```

By default this package use the column name uuid as for the **uuid** attach and preform it on model **creating** event . But these configurations can be changed form the **model-uuid.php** config file.

Also possible to override the uuid column and attaching event from each of the model . to do that need to place the following method in the model :

```
use Touhidurabir\ModelUuid\HasUuid;
use Illuminate\Database\Eloquent\Model;

class User extends Model {

    use HasUuid;

    public function uuidable() : array {

        return [
            'column' => 'uuid',
            'event'  => 'created',
        ];
    }
}
```

Make sure to the put the uuid colun name in migration file

```
$table->string('uuid')->nullable()->unique()->index();
```

Or can be used with the combination of model-uuid config as such:

```
$table->string(config('model-uuid.column'))->nullable()->unique()->index();
```

This package also include some helper method that make it easy to find model records via UUID. for example

```
User::byUuid($uuid)->where('active', true)->first(); // single uuid
User::byUuid([$uuid1, $uuid2])->where('active', true)->get(); // multiple uuid
```

Or simple and direct find

```
User::findByUuid($uuid); // single uuid
User::findByUuid([$uuid1, $uuid2]); // multiple uuid
```

> The package also provide a bit of safe guard by checking if the model table has the given uuid column .
>
> If the uuid column not found for model table schema, it will not create and attach an uuid.

It is also possible to disable the uuid generation for certiain purpose temporarily using the provided **static** method. Then can be enabled again.

```
User::disbaleUuidGeneration(true) // this will diable uuid generation temporarily for model
User::disbaleUuidGeneration(false) // this will enable uuid generation for model again
```

Command
-------

[](#command)

This packaga includes a command that can use to set up the model uuid for the missing ones or update existing one . It will be helpful if this package included later in any laravel app that already have some data in it's tables and needed to set up uuid for those records. To utlize this command run

```
php artisan uuid:regenerate User,Profile
```

The one **argument** it reuired is the name of the models command seperated(if there is multiple models to run for) . Behind the scene it calls a queue job to go through the model recored and work on those to update/fill uuid column value. Other options as follow

### --path=

[](#--path)

By default it assumes all the models are located in the **App\\Models\\** namespace . But if it's located some where else , use the option to define the proper model space path with **trailing slash** .

### --update-all

[](#--update-all)

By default this command will only work with those model records that have the defined uuid column null . So basically it will fill up the missing ones , but if this false is provided with the command it will update all regardless of uuid associated with or not.

### --on-job

[](#--on-job)

This defined if this will update/fill missing one through a queue job . The command use a job where the main logic resides in . But by default it uses the framework provided **dispatchNow** method to run the jon in sync way . if the falg provided and queue configured properly, it will push the job in the queue .

### --job=

[](#--job)

If need to pass custom queue job implementation, it can be directly provided though this option . also one can update the queue class in the config file .

> The default job is defined in the configuration **model-uuid** file as the key **regeneration\_job**.

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
-------

[](#license)

[MIT](./LICENSE.md)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

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 ~12 days

Total

7

Last Release

1709d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c6009d764c48df4a55a8645c349f90a99c7e6e694b06c60b580e1da278d1db5?d=identicon)[touhidurabir](/maintainers/touhidurabir)

---

Top Contributors

[![touhidurabir](https://avatars.githubusercontent.com/u/2587979?v=4)](https://github.com/touhidurabir "touhidurabir (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/touhidurabir-laravel-model-uuid/health.svg)

```
[![Health](https://phpackages.com/badges/touhidurabir-laravel-model-uuid/health.svg)](https://phpackages.com/packages/touhidurabir-laravel-model-uuid)
```

###  Alternatives

[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.3M19](/packages/bavix-laravel-wallet)[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

10.2k3.5k](/packages/leantime-leantime)[google/cloud-bigquery

BigQuery Client for PHP

8919.2M53](/packages/google-cloud-bigquery)[patchlevel/event-sourcing

A lightweight but also all-inclusive event sourcing library with a focus on developer experience

207362.9k13](/packages/patchlevel-event-sourcing)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[markocupic/calendar-event-booking-bundle

Contao Calendar Event Booking Bundle

135.2k1](/packages/markocupic-calendar-event-booking-bundle)

PHPackages © 2026

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