1$users = User::with(['student' => function ($q) {
2 $q->orderBy('id', 'desc');
3 }]);
1add the code to relationship in the method of the model
2 public function room(){
3 return $this->hasMany(room::class, 'id')->orderBy('id', 'DESC') ;
4}