PHPackages                             faaren-tech/laravel-custom-uuids - 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. faaren-tech/laravel-custom-uuids

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

faaren-tech/laravel-custom-uuids
================================

A package to offer Stripe-like uuids for Laravel

1.1.1(3y ago)34.8k↓44.2%1MITPHP

Since Feb 2Pushed 3y ago4 watchersCompare

[ Source](https://github.com/FAAREN-tech/laravel-custom-uuids)[ Packagist](https://packagist.org/packages/faaren-tech/laravel-custom-uuids)[ RSS](/packages/faaren-tech-laravel-custom-uuids/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Custom UUIDs
====================

[](#laravel-custom-uuids)

This package offers uuids like they are used by Stripe, prefixed by the model.

Open Tasks
----------

[](#open-tasks)

- Add command to add this field to existing models

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

[](#installation)

Run the following commands:

```
// Install the package
composer require faaren-tech/laravel-custom-uuids

// Publish relevant stubs for model and migration creation
php artisan custom-uuids:publish-stubs
```

Usage
-----

[](#usage)

### Normal models

[](#normal-models)

Simply keep using the following commands to create models and migrations:

- `php artisan make:model ` to create a new model
- `php artisan make:model  -m` to create a new model and a migration
- `php artisan make:migration ` to create a new migration class

Thanks to the custom stubs, those generated classes will have included the relevant interfaces and/or methods.

**Important**: You have to implement `public function getUuidPrefix(): string` from `FaarenTech\LaravelCustomUuids\Interfaces\HasCustomUuidInterface` by your own.

### User Model and Authenticatable Models

[](#user-model-and-authenticatable-models)

Those models that are a child of `Illuminate\Foundation\Auth\User`, e.g. the `App\User` model, you have to do some additional work.

- Switch the parent class to `FaarenTech\LaravelCustomUuids\Models\UuidModel`
- Add the following interfaces
    - `Illuminate\Contracts\Auth\Access\Authorizable`
    - `Illuminate\Contracts\Auth\Authenticatable`
    - `Illuminate\Contracts\Auth\CanResetPassword`
- Add the following traits to your model
    - `Illuminate\Auth\Authenticatable`
    - `Illuminate\Foundation\Auth\Access\Authorizable`
    - `Illuminate\Auth\Passwords\CanResetPassword`
    - `Illuminate\Auth\MustVerifyEmail`

A possible implementation could look like this:

```
