belongsTo(Event::class); } public function auditions(): HasManyThrough { return $this->hasManyThrough( Audition::class, Event::class, 'id', 'event_id', 'event_id', 'id' )->orderBy('score_order'); } public function seatingLimits(): HasMany { return $this->hasMany(SeatingLimit::class); } public function seats(): HasMany { return $this->hasMany(Seat::class); } public function scopeForAudition(Builder $query, $audition_id): Builder { $audition = Audition::find($audition_id); // get instances of this class where the event_id is equal to the event_id of the audition with $audition_id return $query->where('event_id', $audition->event_id); } public function scopeForEvent(Builder $query, $event_id): Builder { return $query->where('event_id', $event_id); } }