Search code examples
laraveloctobercms

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'


Solution

  • 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.