Download the PHP package slruslan/laravel-eloquent-custom-casts without Composer
On this page you can find all versions of the php package slruslan/laravel-eloquent-custom-casts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download slruslan/laravel-eloquent-custom-casts
More information about slruslan/laravel-eloquent-custom-casts
Files in slruslan/laravel-eloquent-custom-casts
Package laravel-eloquent-custom-casts
Short Description Provides Laravel Eloquent trait to enable custom class object casting.
License GPL
Homepage https://github.com/slruslan/laravel-eloquent-custom-casts
Informations about the package laravel-eloquent-custom-casts
Laravel Eloquent custom casts trait
Laravel Eloquent provides an Attribute Casting function, that allows you to automatically convert attributes to common data types. By default, supported cast types are:
As you can see, custom class types are not supported. This trait adds this support, so you automatically serialize and deserialize your custom classes.
Installation
Using Composer:
Usage
-
Create a field of TEXT type where your data will be stored.
- To enable trait, add line to your Eloquent Model class.
For example:
-
Add your fields and class names to be serialized in protected $casts array.
- You're ready to use your model. Here is a basic example:
License
GNU General Public License v3.0 (GPL). Refer to the LICENSE file to get more info.
Author contacts:
You can ask me any questions by:
Email: [email protected]
VK: vk.com/slruslan