Order By a column on a joined table in laravel
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
Share