I have 6 functions in controllers to order by ASC and DESC 3fields.
Functions:
public function orderByIdAsc(){
$projects = DB::table('projects')->orderBy('id','asc')->get();
return view('cms.public.views.projects.menu', ['projects' => $projects]);
}
public function orderByIdDesc(){
$projects = DB::table('projects')->orderBy('id','desc')->get();
return view('cms.public.views.projects.menu', ['projects' => $projects]);
}
public function orderByOrderAsc(){
$projects = DB::table('projects')->orderBy('order','asc')->get();
return view('cms.public.views.projects.menu', ['projects' => $projects]);
}
public function orderByOrderDesc(){
$projects = DB::table('projects')->orderBy('order','desc')->get();
return view('cms.public.views.projects.menu', ['projects' => $projects]);
}
public function orderByPublicAsc(){
$projects = DB::table('projects')->orderBy('public','asc')->get();
return view('cms.public.views.projects.menu', ['projects' => $projects]);
}
public function orderByPublicDesc(){
$projects = DB::table('projects')->orderBy('public','desc')->get();
return view('cms.public.views.projects.menu', ['projects' => $projects]);
}
With her 6 routes too:
Route::prefix('admin')->group(function () {
Route::get('project/orderByIdAsc', ['uses' => 'AdminController@orderByIdAsc', 'as' => 'admin.projects.orderByIdAsc']);
Route::get('project/orderByIdDesc', ['uses' => 'AdminController@orderByIdDesc', 'as' => 'admin.projects.orderByIdDesc']);
Route::get('project/orderByOrderAsc', ['uses' => 'AdminController@orderByOrderAsc', 'as' => 'admin.projects.orderByOrderAsc']);
Route::get('project/orderByOrderDesc', ['uses' => 'AdminController@orderByOrderDesc', 'as' => 'admin.projects.orderByOrderDesc']);
Route::get('project/orderByPublicAsc', ['uses' => 'AdminController@orderByPublicAsc', 'as' => 'admin.projects.orderByPublicAsc']);
Route::get('project/orderByPublicDesc', ['uses' => 'AdminController@orderByPublicDesc', 'as' => 'admin.projects.orderByPublicDesc']);
});
For the moment i call to the functions here:
<th><a href="{{ route('admin.projects.orderByIdAsc')}}"><span class="glyphicon glyphicon-arrow-up" id="orderByIdAsc"></span></a>Id<a href="{{ route('admin.projects.orderByIdDesc')}}"><span class="glyphicon glyphicon-arrow-down" id="orderByIdDesc"></span></a></th>
<th>Slug</th>
<th><a href="{{ route('admin.projects.orderByOrderAsc')}}"><span class="glyphicon glyphicon-arrow-up" id="orderByOrderAsc"></span></a>Order<a href="{{ route('admin.projects.orderByOrderDesc')}}"><span class="glyphicon glyphicon-arrow-down" id="orderByOrderDesc"></span></a></th>
<th><a href="{{ route('admin.projects.orderByPublicAsc')}}"><span class="glyphicon glyphicon-arrow-up" id="orderByPublicAsc"></span></a>Public<a href="{{ route('admin.projects.orderByPublicDesc')}}"><span class="glyphicon glyphicon-arrow-down" id="orderByPublicDesc"></span></a></th>
Any way to do it with ajax easier than make 6 divs and hide / display it?
Thanks a lot!