Sorting related models in Laravel

Posted: 2014-08-15 11:00:05

There are a number of related models to this one model that I store in the Models $relations property

    protected static $relations = [

This allows me to easily reuse this for each query

$found = $found->load(static::$relations);

But there is one model I removed from that list to do a dynamic query/sorting on it

        $found = $this->property->with([
            'verifiers' => function($query) {
                    $query->with('user.profiles')->orderBy('id', 'DESC');
        $found = $found->load(static::$relations);

veifiers was part of the protected static $relations list but I moved it out since, for each query, I need to sort them from last to first.