Sign Up

Sign In

Forget Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask question.

Developers Map

Order By a column on a joined table in laravel

  • 0

Laravel is a most common framework. it is very easy to use and learn.if when we apply relation between two table using model but when we want sorting by joined table column.then you should use below code in your model.

Use Below Code :

public function RELATION_NAME()
{
     return $this->hasOne('App\Models\YOUR_MODEL', 'YOUR_ID')->orderBy('YOUR_COLUMN_NAME', 'ASC');;
}  

For More Info CLICK HERE

Leave an answer

Leave an answer

Browse