Download the PHP package philippgrashoff/atkdatamodeltraits without Composer
On this page you can find all versions of the php package philippgrashoff/atkdatamodeltraits. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download philippgrashoff/atkdatamodeltraits
More information about philippgrashoff/atkdatamodeltraits
Files in philippgrashoff/atkdatamodeltraits
Package atkdatamodeltraits
Short Description A small collection of traits to be used with Atk4\Data\Model
License
Informations about the package atkdatamodeltraits
atkdatamodeltraits
A small collection of traits to be used with Atk4\Data\Model.
CreatedDateAndLastUpdatedTrait
This trait can be used to add a created_date
and/or a last_updated
field to a model. The corresponding hooks are automatically added to save created_date
on insert and last_updated
on update.
UniqueFieldTrait
This trait provides a function isFieldUnique()
to check if the field's current value is unique among all records in persistence.
This functionality can also be achieved by adding a UNIQUE index to an SQL persistence. Having this functionality in the application layer
can be sensible to be independent of the persistence's features - or to avoid getting back an exception from the persistence if a non-unique value is being tried to save.
CryptIdTrait
This trait is used to generate cryptic IDs like D6f2-a395Jskv2
. You can freely define the format the cryptic ID shall have.
The functionality can for example be used to create coupon codes or create unguessable, yet human-readable codes/identifiers.
The characters I,l,0 and O are removed as they can be easily be mistaken by humans.
To use this trait, you just need to add the cryptic ID field in Model::init()
using addCryptIdFieldAndHooks
and implement a custom method
generateCryptId()
that returns a random string in the format of your choice: