I have this object and as you can see I sort by different variables
$banks = Bank::with('credits')->with('deposits')->with('bank_assets')->with('atms')->get()->sortByDesc($sort);
So I have relations in my model for example bank_assets (credits and deposits working clearly and i can sort by deposit or by credit) But bank_assets! No In this case I need to sort by actives which I need to calculate. Because Actives this is a summ of different ammounts from this table http://prntscr.com/ij3idg And In my model relation I get only the object not a summ of this amounts As you can see
//Bank Model
public function bank_assets()
{
return $this->hasMany('App\BankRating')->where('type','assets');
}
But I need to sort by actives which is a summ of different amounts Please Help me and Explaine How I can sort