Tags provide a way to relate otherwise unrelated models, enabling features like dynamic collections.Documentation Index
Fetch the complete documentation index at: https://docs.lunarphp.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Tags provide a way to relate otherwise unrelated models in the system. They also impact other features such as Dynamic Collections. For example, two products “Blue T-Shirt” and “Blue Shoes” are unrelated by nature, but adding aBLUE tag to each product allows a Dynamic Collection to include any products with that tag.
Fields
| Field | Type | Description |
|---|---|---|
id | id | Primary key |
value | string | The tag value |
created_at | timestamp | |
updated_at | timestamp |
Enabling tags
To enable tagging on a model, add theHasTags trait:
syncTags:
syncTags method accepts a collection of Tag models. Tags are automatically converted to uppercase when saved. The sync process runs via a queued job (Lunar\Jobs\SyncTags), so changes may not be reflected immediately if using an asynchronous queue driver.