This is my index function in controller page of category , i want to arrange all categories in alphabetical order , right now my categories are sorted with id number , what code i have to add
this is code in controller page of category-
public function index(Request $request)
{
$data = Data::orderBy('category_name')->get();
return view('auth.category');
}
& that is code in model page of category-
class addcategory extends Model{
use HasFactory;
public static function insert($array){
$data= DB::table('tbl_category')->insert($array);
return $data;
}
}