Overview
Attributes can be associated to Eloquent models to allow custom data to be stored. Typically, these will be used the most with Products where different information is needed to be stored and presented to visitors. For example, a television might have the following attributes assigned…- Screen Size
 - Screen Technology
 - Tuner
 - Resolution
 
Attributes
| Field | Description | 
|---|---|
attribute_type | Morph map of the model type that can use attribute, e.g. product | 
attribute_group_id | The associated group | 
position | An integer used to define the sorting order of attributes within attribute groups | 
name | Laravel Collection of translations {'en': 'Screen Size'} | 
handle | Kebab-cased reference, e.g. screen-size | 
section | An optional name to define where an attribute should be used. | 
type | The field type to be used, e.g. Lunar\FieldTypes\Number | 
required | Boolean | 
default_value | |
configuration | Meta data stored as a Laravel Collection | 
system | If set to true, indicates it should not be deleted | 
Field Types
| Type | Config | 
|---|---|
Lunar\FieldTypes\Number | Integer or Decimal | 
Lunar\FieldTypes\Text | Single-line, Multi-line, Rich Text | 
Lunar\FieldTypes\TranslatedText | Single-line, Multi-line, Rich Text | 
Lunar\FieldTypes\ListField | An re-orderable list of text values | 
Models that use Attributes
- Lunar\Models\Product
 - Lunar\Models\ProductVariant
 - Lunar\Models\Collection
 
Saving Attribute Data
Adding attributes to your own model
attribute_data.
::: tip
When loading models it is advised you eager load the attribute data required.
:::
Accessing Attribute Data.
There will come times where you need to be able to retrieve the attribute data you have stored against a model. When you target theattribute_data property it will be cast as a collection and resolved into it’s corresponding field type.
translateAttribute method on the model:
Advanced usage
Attribute Groups
Attribute Groups form a collection of attributes that are logically grouped together for display purposes. A good example might be an “SEO” attribute group which has attributes for “Meta Title” and “Meta Description”.| Field | Description | 
|---|---|
name | Laravel Collection of translations {'en': 'SEO'} | 
handle | Kebab-cased reference, e.g. seo | 
position | An integer used to define the sorting order of groups |