Download the PHP package lesichkovm/laravel-advanced-model without Composer
On this page you can find all versions of the php package lesichkovm/laravel-advanced-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lesichkovm/laravel-advanced-model
More information about lesichkovm/laravel-advanced-model
Files in lesichkovm/laravel-advanced-model
Package laravel-advanced-model
Short Description Advanced model class for Laravel
License proprietary
Homepage http://github.com/lesichkovm/laravel-advanced-model
Informations about the package laravel-advanced-model
Laravel Advanced Model
An advanced model for Laravel. Has out-of-the-box support for SnakeCase (Laravel's default), as well as for CamelCase field names, and enhanced primary key support - human friendly date based unique IDs, and UUIDs.
Background
-
Snake case (snake_case) advanced model. This is the default Laravel's model. This model uses the foillowing fields:
-
Camel case (CamelCase). Camel case is more readable and a bit shorter than snake case (more at https://en.wikipedia.org/wiki/Camel_case). This model changes the default Laravel names to:
- The default Laravel model uses only incremental primary keys. Though it works for basic use cases, this causes extra effort for deduping records on larger systems. A much better option is to use unique IDs. This class supports UUIDs, as well as more human friendly unique unique IDs (HUID).
Human-friendly Unique IDs (HUIDs)
The Human-friendly unique IDs (HUIDs) are numeric strings consisting of the date and time with a random variable length postfix. The usual length is 20, but can be increased, if more uniqueness is required. Example: 20170715081335698999
The HUIDs are less unique than UUIDs, but have more value for everyday usage:
- They do provide enough information to uniquely identify a record in 99.99% of the user cases.
- Being date based provides answer when the record was created.
- Can be ordered in ascending/descending order as they are numeric
- Unlike UUIDs are easy for humans to read, especially when separated with dashes
- Can be further transferred to other numeric bases
Installation
- Using composer
Usage
Extend your model classes
-
Using AdvancedSnakeCaseModel
-
Using AdvancedCamelCaseModel
-
Human-friendly Unique ID (HUID)
-
Universally Unique ID (UUID)
- Autoincrements
Create Model and Retrieve ID
-
Create snake case model instance and retrieve ID
- Create new camel case model instance and retrieve ID
Additional Methods
-
chunks($perChunk)
-
getConnName
-
getTableName
-
trash
- untrash