Adds Dynamic Attributes to your Models
marmarait/laravel-dynamic-attributes is a Laravel package for adds dynamic attributes to your models.
It currently has 0 GitHub stars and 31 downloads on Packagist (latest version v1.02).
Install it with composer require marmarait/laravel-dynamic-attributes.
Discover more Laravel packages by marmarait
or browse all Laravel packages to compare alternatives.
Last updated
Add Additional Fields to your Models with a key value table
composer require marmarait/laravel-dynamic-attributes
add the Trait "HasDynamicAttributes" to your model
in the method "getDynamicAttributes" return an array with the dynamic attributes and their field types. Available are:
Use it as you normally would with static attributes.
Example:
If you want your Users Model to have an additional field named "country" with type string:
Add HasDynamicAttributes to your User model
Make the getDynamicAttributes method return ['country'=>'string']
Set the field by assigning the property to the model:
$user->country='Austria';
Retrieving the Property is about the same:
echo $user->country; // 'Austria'