Download the PHP package faaren-tech/laravel-custom-uuids without Composer
On this page you can find all versions of the php package faaren-tech/laravel-custom-uuids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download faaren-tech/laravel-custom-uuids
More information about faaren-tech/laravel-custom-uuids
Files in faaren-tech/laravel-custom-uuids
Package laravel-custom-uuids
Short Description A package to offer Stripe-like uuids for Laravel
License MIT
Informations about the package laravel-custom-uuids
Laravel Custom UUIDs
This package offers uuids like they are used by Stripe, prefixed by the model.
Open Tasks
- [ ] Add command to add this field to existing models
Installation
Run the following commands:
Usage
Normal models
Simply keep using the following commands to create models and migrations:
php artisan make:model <MyModel>
to create a new modelphp artisan make:model <MyModel> -m
to create a new model and a migrationphp artisan make:migration <CreateMyModelTable>
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
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:
Customize stubs
Of course, you are free to customize the given stubs. They are stored in */stubs
.