Download the PHP package rawaby88/muid without Composer
On this page you can find all versions of the php package rawaby88/muid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rawaby88/muid
More information about rawaby88/muid
Files in rawaby88/muid
Informations about the package muid
Laravel Model unique identifier (MUID)
Laravel package to generate a random ID with your prefix for your Eloquent models
Example
Available 3 lengths of Muid
MUID | Char count |
---|---|
tiny |
16 char |
small |
24 char |
standard |
36 char |
the length can be altered from the config file if you wish.
Laravel | Package |
---|---|
v8.* |
v1.* |
v9.* |
v2.* |
v10.* |
v3.* |
Installation
You can install the package via Composer:
Usage
You can extend the provided model classes, or by using a trait
Extending model
When creating an Eloquent model, instead of extending the standard Laravel model class, extend from the model class provided by this package:
Extending user model
Extending the User class provided by this package:
Using trait
As an alternative to extending the classes in the examples above, you also have the ability to use the provided trait instead
prefix
in order to generate the prefix for your muid, you will need to provide this information in the model itself
by adding $keyPrefix
, if no prefix provided muid will be generated without prefix
Creating models
In addition to the make:model
artisan command, you will now have access to
muid:make:model
which has all the functionality of the standard make:model
command (with the exception of not being able to create a pivot model):
Database migration
This package includes all types to generate your MUID in an easy way
lists of available Blueprints:
Blueprint | Size | Description |
---|---|---|
standard | ||
primaryMuid |
36 |
Create a new muid column as the primary key(s) for the table |
muid |
36 |
Create a new muid column on the table |
foreignMuid |
36 |
Create a new muid column on the table with a foreign key constraint |
muidMorphs |
36 |
Add the proper columns for a polymorphic table using MUIDs |
nullableMuidMorphs |
36 |
Add nullable columns for a polymorphic table using MUIDs |
small | ||
primarySmallMuid |
24 |
Create a new muid column as the primary key(s) for the table |
smallMuid |
24 |
Create a new muid column on the table |
foreignSmallMuid |
24 |
Create a new muid column on the table with a foreign key constraint |
muidSmallMorphs |
24 |
Add the proper columns for a polymorphic table using MUIDs |
nullableSmallMuidMorphs |
24 |
Add nullable columns for a polymorphic table using MUIDs |
tiny | ||
primaryTinyMuid |
16 |
Create a new muid column as the primary key(s) for the table |
tinyMuid |
16 |
Create a new muid column on the table |
foreignTinyMuid |
16 |
Create a new muid column on the table with a foreign key constraint |
muidTinyMorphs |
16 |
Add the proper columns for a polymorphic table using MUIDs |
nullableTinyMuidMorphs |
16 |
Add nullable columns for a polymorphic table using MUIDs |
Migration example
Publish Config
Once done, publish the config to your config folder using:
Configuration
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- Mahmoud Osman
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.