Jakef19
Jakef19

Reputation: 311

October CMS relationships

I have 3 models.

Quote Status Event

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'

Upvotes: 0

Views: 210

Answers (1)

Hardik Satasiya
Hardik Satasiya

Reputation: 9693

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.

Upvotes: 1

Related Questions