I have a Asset
model and AssetCategory
model. The asset
model has function
$this->belongsTo('App\AssetCategory' ); //inverse one to one
My assets
table has columns id
, name
, assetcategory_id
.
Now, when I want to populate my assets list and sort it according to asset name, I can simply write
$assets = Asset::orderBy('name' , 'asc')->get();
But how do I sort according to the asset categories that are populated in my output. I am using laravel 5.3