Can u try in your controller
$cars = Car::all()->orderBy('sort_order', 'asc')->get();
for car.php model
public function scopeMyOrder($query)
{
return $query->orderBy('sort_order', 'asc');
}
and call this to CarsController.php
$cars = Car::myOrder()->get();
Thank you Mr. say! That worked great. scope is exactly the solution I need.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community