I have an eloquent query which returns a with a hasMany
relationship. With that relationship, I now need to display data from another relationship. Is this possible with a single query?
My Eloquent query fetching with a relationship;
$tickets = Tickets::with('ticketQuestions')->where('event_id', $id)->get();
My TicketQuestions
model also has the following relationship;
public function questions() {
return $this->belongsTo(Questions::class);
}
Is it possible to fetch the questions from the Questions
model as well?
So that my page can display the tickets, the ticket questions (look up table), and the questions themselves.