Answers for "sort eloquent hasmany"

PHP
0

laravel sortby relationship column

add the code to relationship in the method of the model
   public function room(){
      return $this->hasMany(room::class,  'id')->orderBy('id', 'DESC') ;
}
Posted by: Guest on July-22-2021
0

laravel OrderBy on Eloquent whereHas relationship

$counties = County::whereHas('items', function ($query) {
    $query->where('approved', 1);
})->orderBy('name')->get();
Posted by: Guest on May-07-2020

Code answers related to "sort eloquent hasmany"

Browse Popular Code Answers by Language