Laravel Sortby Relationship Column

[Solved] Laravel Sortby Relationship Column | Php Frameworks Yii - Code Explorer | yomemimo.com
Question : laravel orderby with relation

Answered by : nothing

$users = User::with(['student' => function ($q) { $q->orderBy('id', 'desc'); }]);

Source : https://laracasts.com/discuss/channels/eloquent/order-by-on-relationship | Last Update : Mon, 11 May 20

Question : laravel sortby relationship column

Answered by : busy-bird-b6877g419sh1

add the code to relationship in the method of the model public function room(){ return $this->hasMany(room::class, 'id')->orderBy('id', 'DESC') ;
}

Source : | Last Update : Thu, 29 Jul 21

Answers related to laravel sortby relationship column

Code Explorer Popular Question For Php Frameworks Yii