Download the PHP package bigsinoos/j-eloquent without Composer
On this page you can find all versions of the php package bigsinoos/j-eloquent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package j-eloquent
Deprecation Notice
For newer versions of Laravel just use the simple attribute casting functionality which is a really nicer approach.
What is j-Eloquent?
Thanks to Laravel, Django and Rails we all know that convention over configuration (CoC) makes the development more funny. So suppose that you want to convert the Gregorian date attributes of your models to Jalali (persian) dates, in this case helps you to convert them conventionally, for example when you access a property named on your model, the detects the convention automatically and tries to convert property of your model if it is a date attribute. This is also true for and fields.
Installation
require following line in your composer secion :
Requirement
this package requires : miladr/jalali
Features
- Coneventionally converts Eloquent model date attributes to Jalali date when the original date attribute is accessed prefixed by a string like .
- Automatically converts date attributes to Jalali dates when model's , and are called.
- Custom date formats can be set for dates.
Documentation
The :
By using trait in your models you can enable the plugin :
Usage
By default you can access your eloquent date attributes in jalali date by adding a substring to the begining of your original attribute like :
Changing prefix
You can change the jalali date convention prefix with overriding and or by overrriding property on your model class :
Custom date attributes :
You can tell Eloquent that which one of your fields are date attributes like created_at and updated_at, then Eloquent treats them like objects you define multiple date attributes like this :
When using the above trait all of the fields that are treated like date objects by Laravel will be available for conventional converting. They will be also added to model's , and methods.
Converter helper method
The method allowes you to normally convert one of your fields, from Gregorian date to Jalali date :