Is it possible to filter a result set in Laravel's Eloquent ORM by related models? I understand that Eloquent does not join tables but the results I would like would be similar to:
SELECT * FROM tickets JOIN statuses on tickets.status_id = statuses.id WHERE statuses.name != 'Closed';
The closest functionality I have found in Eloquent is:
$tickets = Ticket::with(array('status' => function($q) {
return $q->where('name', '!=', 'Closed');
}))->get();
This will still return all of the tickets but only the statuses relation if the name is not closed.
Also, I know this can be done in Fluent, but I would like to work with the returned structure of nested objects that Eloquent provides:
echo ticket->status->name;
Fluent returns a flattened result as a joined query would.