Overview
Channels allow products and other models to be published to different storefronts or sales channels. Lunar installs a defaultwebstore channel during setup.
Fields
| Field | Type | Description |
|---|---|---|
id | id | Primary key |
name | string | The display name of the channel |
handle | string | URL-friendly identifier, automatically slugified on save |
default | boolean | Whether this is the default channel |
url | string nullable | An optional URL associated with the channel |
created_at | timestamp | |
updated_at | timestamp | |
deleted_at | timestamp nullable |
Relationships
| Relationship | Type | Related Model | Description |
|---|---|---|---|
products | MorphToMany | Lunar\Models\Product | Products assigned to this channel |
collections | MorphToMany | Lunar\Models\Collection | Collections assigned to this channel |
discounts | MorphToMany | Lunar\Models\Discount | Discounts assigned to this channel |
Scopes
| Scope | Description |
|---|---|
default($default = true) | Filter to the default channel |
Assigning channels to models
Models can be assigned to different channels and optionally scheduled for availability within a date range. To add this functionality to a model, use theHasChannels trait:
scheduleChannel method becomes available:
channel scope available to models using this trait: