PHPackages                             waska14/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. waska14/laravel-uuid

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

waska14/laravel-uuid
====================

Use uuid in models easily

2.0.2(5y ago)516.1k↓50%MITPHPPHP &gt;=5.5.9

Since Nov 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/waska14/laravel-uuid)[ Packagist](https://packagist.org/packages/waska14/laravel-uuid)[ Docs](https://github.com/waska14/laravel-uuid)[ RSS](/packages/waska14-laravel-uuid/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (5)Used By (0)

Laravel-Uuid
============

[](#laravel-uuid)

**If you want to use uuid columns and fill them automatically, this package is for you.**

This is a Laravel package for using (auto-generating) uuid in models. With this package you write less code, as the uuid(s) are being created, when you first save your instances.

### Docs

[](#docs)

- [Laravel compatibility](#laravel-compatibility)
- [Installation](#installation)
- [Migrations](#migrations)
- [Models](#models)
- [Configuration](#configuration)
- [Other usage](#other-usage)

Laravel compatibility
---------------------

[](#laravel-compatibility)

LaravelCompatible&gt;=5.1✓Installation
------------

[](#installation)

Add the package in your composer.json by executing the command.

```
composer require waska14/laravel-uuid
```

Next, add the service provider in your `config/app.php`

```
'providers' => [
    ....
    Waska\LaravelUuid\UuidServiceProvider::class,
    ....
],
```

Migrations
----------

[](#migrations)

```
// 2.1 If you want to use uuid column as primary column:
Schema::create('students', function(Blueprint $table)
{
    $table->uuid('uuid')->primary();
    $table->string('name');
    $table->string('last_name');
    ...
});

// 2.2 If you want to use uuid column as non-primary column:
Schema::create('students', function(Blueprint $table)
{
    $table->increments('id');
    $table->uuid('uuid')->unique();
    $table->string('name');
    $table->string('last_name');
    ...
});

// 2.3 If you want to use multiple uuid columns (maybe on of them is primary):
Schema::create('students', function(Blueprint $table)
{
    $table->uuid('uuid')->primary();
    $table->uuid('uuid_column_2')->unique();
    $table->uuid('uuid_column_3')->unique();
    $table->string('name');
    $table->string('last_name');
    ...
});
```

*Note: If uuid column is not primary, you should make it unique, or manually index the column.*

Models
------

[](#models)

1. You must use trait in model

```
class Student extends Model
{
    use \Waska\Traits\Uuid;
}
```

2.1 If you are using uuid column as primary key and column\_name **is default** `id`, you need nothing more.

2.2 If you are using uuid column as primary key and column\_name **is not default** `id`, you must define `protected $primaryKey` and `protected $uuid_column`:

```
class Student extends Model
{
    use \Waska\Traits\Uuid;

    protected $primaryKey = "uuid_primary_column_name";
    protected $uuid_column = "uuid_primary_column_name";

    protected $fillable = [
        'name',
        'last_name',
    ];
}
```

2.3 If you are using non-primary uuid column and **column name equals to `default_column_name`** (`uuid` from config), you need only to append column name in `protected $fillable`:

```
class Student extends Model
{
    use \Waska\Traits\Uuid;

    protected $fillable = [
        'name',
        'last_name',
        'uuid', // config/waska.uuid.php -> default_column_name
    ];
}
```

2.4 If you are using non-primary uuid column and **column name doesn't equal to `default_column_name`** (`uuid` from config), you need define `protected $uuid_column` and append column name in `protected $fillable`:

```
class Student extends Model
{
    use \Waska\Traits\Uuid;

    protected $uuid_column = "uuid_column_name";

    protected $fillable = [
        'name',
        'last_name',
        'uuid_column_name',
    ];
}
```

2.5 If you are using multiple uuid columns (if one of them is primary, you must do step ***2.1*** at first), you need define `protected $uuid_column` **as an array** and append column names (*only non-primary*) in `protected $fillable`

```
class Student extends Model
{
    use \Waska\Traits\Uuid;

    protected $primaryKey = "uuid_primary_column_name"; // If one of them is primary
    protected $uuid_column = ["uuid_column_name1", "uuid_column_name2", "uuid_column_name3"];

    protected $fillable = [
        'name',
        'last_name',
        'uuid_column_name1',
        'uuid_column_name2',
        'uuid_column_name3',
    ];
}
```

2.6 Now when you create new `Student` object, uuid(s) will be generated **automatically**

```
Student::create([
    'name'      => "Bill',
    'last_name' => "Gates',
]);

// or
$student = new Student([
    'name'      => "Bill',
    'last_name' => "Gates',
]);
$student->save();

// or
$student = new Student();
$student->name = "Bill";
$student->last_name = "Gates";
$student->save();
```

Configuration
-------------

[](#configuration)

***If you want to change default configuration***, you must publish default configuration file to your project.

You can publish config by running this in console:

```
php artisan vendor:publish --tag=waska-uuid-config
```

*Note: If you're going to use **v3** or **v5** uuid, it's recommended to change **v3\_default\_namespace**and **v5\_default\_namespace** with valid uuid strings .*

*Generate them with this command in tinker (Start tinker: `php artisan tinker`)*

```
Waska\Uuid::get(4); // This command will generate valid uuid (v4, pseudo-random) string
```

Other usage
-----------

[](#other-usage)

Generate uuid (**Universal Unique Identifier**)

```
/**
 * This generates name-based Uuid
 * @param int $version.
 * @param string $name. String which the uuid is generating for.
 * @param string $namespace. Valid uuid string. Default value is defined in config/waska.uuid.php
 * @return String
 */
Waska\Uuid::get(3, "some_random_string", "valid_uuid");

// This generates pseudo-random Uuid
Waska\Uuid::get(); // Default version is 4, so it means: Waska\Uuid::get(4);

/**
 * This generates name-based Uuid
 * @param int $version.
 * @param string $name. String which the uuid is generating for.
 * @param string $namespace. Valid uuid string. Default value is defined in config/waska.uuid.php
 * @return String
 */
Waska\Uuid::get(5, "some_random_string", "valid_uuid");
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

4

Last Release

2000d ago

Major Versions

1.1.0 → 2.0.22020-11-20

### Community

Maintainers

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

---

Top Contributors

[![waska14](https://avatars.githubusercontent.com/u/19436616?v=4)](https://github.com/waska14 "waska14 (12 commits)")

---

Tags

laraveluuidgenerate

### Embed Badge

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

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

###  Alternatives

[webpatser/laravel-uuid

Laravel integration for webpatser/uuid - High-performance drop-in UUID replacements (15% faster than Ramsey). Provides Str macros, HasUuids trait, facades, and casts. RFC 4122/9562 compliant.

1.8k17.3M129](/packages/webpatser-laravel-uuid)[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[dirape/token

Unique Token Generator For Laravel

28277.4k2](/packages/dirape-token)[madewithlove/laravel-nova-uuid-support

Adds uuid and other string identifier support to Laravel Nova

28132.9k](/packages/madewithlove-laravel-nova-uuid-support)[riipandi/laravel-optikey

Use UUID, Ulid, or nanoid as optional or primary key in Laravel.

429.1k](/packages/riipandi-laravel-optikey)[okipa/laravel-form-components

Ready-to-use and customizable form components.

198.0k1](/packages/okipa-laravel-form-components)

PHPackages © 2026

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