Download the PHP package your-app-rocks/eloquent-uuid without Composer
On this page you can find all versions of the php package your-app-rocks/eloquent-uuid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download your-app-rocks/eloquent-uuid
More information about your-app-rocks/eloquent-uuid
Files in your-app-rocks/eloquent-uuid
Package eloquent-uuid
Short Description Adds support for UUID generation automatically for Models Eloquents.
License MIT
Homepage https://yourapp.rocks
Informations about the package eloquent-uuid
Eloquent UUID
Simple and flexible Laravel package that adds support for UUID generation automatically for any Eloquent model.
- Generate
uuid
automatically. - Choose a custom name for the
uuid
column in your table. (default 'uuid') - Choose the version of the generated uuid. (default '4')
- Checks for
uuid version
andcolumn name
. (throws the InvalidUuidVersionException and MissingUuidColumnException exceptions) - Prevents update on uuid value.
What is a UUID?
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. is a 36 character long identifier made up of 32 alphanumeric characters with four hyphens in amongst it.
For example:123E4567-E89b-12D3-A456-426655440000
containing letters and numbers. that will uniquely identify something. you can read more here.
Installation
You can install the package via Composer:
or via composer.json
file
Usage
Create table
Create your table with a uuid
column. For example:
Create model
In your eloquent model, add trait HasUuid
:
Create Controller
Customization
You can easily config the package for your needs by changing the column name and uuid version. For example:
Advance Customization
This package was built to be flexible and easy to customize!
You can use trait Uuidable
to create your own trait with your custom code.
Methods
YourAppRocks\EloquentUuid\Traits\Uuidable;
- getUuidColumnName()
// Get the column name. ( default 'uuid' )
- getUuid()
// Get the uuid value.
- setUuid($value)
// Set the uuid value.
- generateUuid()
// Generate the UUID value. ( Using Ramsey\Uuid )
- getUuidVersion()
// Get uuid version or default to 4.
- getUuidString()
// Get string to generate uuid version 3 and 5.
- validateUuidVersion()
// Validate uuid version.
Example custom code
Replacing trait HasUuid
for MyUuidTrait
:
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
- João Roberto
- All Contributors
This package is inspired by this package.
License
The MIT License (MIT). Please see License File for more information.