marmarait/laravel-dynamic-attributes

Adds Dynamic Attributes to your Models

Installs: 31

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:libary

pkg:composer/marmarait/laravel-dynamic-attributes

v1.02 2018-08-31 18:32 UTC

This package is not auto-updated.

Last update: 2025-10-12 11:10:41 UTC


README

Overview

Add Additional Fields to your Models with a key value table

Install

composer require marmarait/laravel-dynamic-attributes

Usage

  • add the Trait "HasDynamicAttributes" to your model

  • in the method "getDynamicAttributes" return an array with the dynamic attributes and their field types. Available are:

    • string
    • text
    • int
    • double
    • object
    • date
    • time
    • datetime
  • 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'