Download the PHP package jetcod/eloquent-keygen without Composer
On this page you can find all versions of the php package jetcod/eloquent-keygen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jetcod/eloquent-keygen
More information about jetcod/eloquent-keygen
Files in jetcod/eloquent-keygen
Package eloquent-keygen
Short Description A Laravel package providing seamless integration with Snowflake ID generation for Eloquent models
License MIT
Informations about the package eloquent-keygen
Eloquent KeyGen
This is a Laravel package providing seamless integration with Snowflake ID generation for Eloquent models. Simplify primary key management with automatic generation using a highly distributed unique identifier system. Enhance your application's scalability and efficiency with this easy-to-use package for Laravel Eloquent models.
Installation
To install jetcod/deloquent-keygen, you can use Composer, the dependency manager for PHP. Run the following command in your terminal:
Then you need to publish the config file:
How to use?
To use the package, follow these steps:
- Extend Your Model:
Instead of extending Illuminate\Database\Eloquent\Model, extend Jetcod\Eloquent\Model in your Eloquent model. This will enable automatic ID generation using the Snowflake algorithm.
- Using Trait:
If you don't want to extend the Eloquent model, or you want to apply the Snowflake ID generation to one model, you can use the Snowflake trait in your model class.
- Disable Snowflake Generation for a Model:
If you want to disable the Snowflake ID generation for a particular model, you can add a snowflake method to that model returning false.
The snowflake method returns a boolean value indicating whether the Snowflake ID generation should be enabled or disabled for that model.
- Configuration for distributed system:
The package uses the following configuration to generate the distributed unique identifier:
Support the Project
If Eloquent KeyGen saves you time or is useful in your work, you can support its continued development through Buy Me a Coffee. Support helps with ongoing maintenance, bug fixes, documentation, compatibility updates, and future improvements. Contributions are appreciated but entirely optional, and the project remains available to everyone.
License
This project is licensed under the MIT License - see the LICENSE file for details.
