I have a request in my controller:
$model = Object::find()->where(['id' => $id])->with(['backups'])->one();
getBackups is a hasMany () relation, so the $ model returns several "backups".
Is there a way to order "backups"?
I tried the following without results (or errors):
$model = Object::find() ->where(['id' => $id]) ->with(['backups' => function($query) { $query->orderBy(['updated_at' => SORT_DESC]); }]) ->one();
source share