PHPackages                             yieldstudio/eloquent-public-id - 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. yieldstudio/eloquent-public-id

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

yieldstudio/eloquent-public-id
==============================

Eloquent Public ID Trait for Laravel 9 and above.

1.0.5(1y ago)058.0k↓45.5%1MITPHPPHP ^8.0|^8.1|^8.2CI passing

Since Jun 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/YieldStudio/eloquent-public-id)[ Packagist](https://packagist.org/packages/yieldstudio/eloquent-public-id)[ Docs](https://github.com/YieldStudio/eloquent-public-id)[ RSS](/packages/yieldstudio-eloquent-public-id/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (7)Used By (0)

Eloquent Public Id
==================

[](#eloquent-public-id)

[![Latest Version](https://camo.githubusercontent.com/b5aed87cc761cf588ff966439d86aad6d6bca9be14f4a79d49a584916b30a6bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7969656c6473747564696f2f656c6f7175656e742d7075626c69632d69643f7374796c653d666c61742d737175617265)](https://github.com/yieldstudio/eloquent-public-id/releases)[![GitHub Workflow Status](https://camo.githubusercontent.com/14cab664f88d351ebf85101c68414e12f3ca57d7b7ee09a26547ff1782ebf72d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7969656c6473747564696f2f656c6f7175656e742d7075626c69632d69642f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/yieldstudio/eloquent-public-id/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/fcfcd2ef2672d2d1022a989dcec1e3cbb9a782b69ff23f25ada534b68453b04a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7969656c6473747564696f2f656c6f7175656e742d7075626c69632d69643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yieldstudio/eloquent-public-id)

What It Does
------------

[](#what-it-does)

The interest of public IDs is to keep a whole and incremental ID, while having a UUID to expose to the front end, which can be convenient for security reasons.

This package offers two features:

- Allow models to manage a public ID
- Allow FormRequest to easily convert public IDs to IDs

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

[](#installation)

You can install the package via composer:

```
composer require yieldstudio/eloquent-public-id
```

HasPublicId Trait
-----------------

[](#haspublicid-trait)

This Trait will enable your Model to have benefit of all the actions needed to process the public id.

Once package installed, Add a public id field into your table

```
Schema::create('users', function (Blueprint $table) {
    // ..
    $table->uuid('public_id')->index()->unique();
    // ..
});
```

Next step, use the HasPublicId trait into your Model

```
