Ad

October CMS Relationships

- 1 answer

I have 3 models.

QuoteStatusEvent

1 Quote belongs to 1 Status and 1 Event. However Status and Event can have many Quote.

How do i set this relationship up?

Here is an example:

I create a new quote and select 'Active' as the Status and the Event as 'Golf'

Ad

Answer

You have done great

Quote -> bleongsTo -> Status 
Quote -> bleongsTo -> Event

Status -> hasMany -> Quote
Event -> hasMany -> Quote

if we convert it to OctoberCMS relations

// Quote
public $belongsTo = [
    'status' => ...
    'event' => ...
];

// Status
public $hasMany = [
    'quotes' => ...
];


// Event
public $hasMany = [
    'quotes' => ...
];

you can make relations like this

if any doubt please comment.

Ad
source: stackoverflow.com
Ad