Answers for "how to use orderby in laravel for two columns"

PHP
1

laravel multiple orderby

User::orderBy('name', 'DESC')
    ->orderBy('email', 'ASC')
    ->get();
Posted by: Guest on June-05-2020
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

Browse Popular Code Answers by Language