Last active
August 8, 2017 19:01
-
-
Save azimidev/21d3a10658f97025e7ee4bf0a5f3a6cd to your computer and use it in GitHub Desktop.
Laravel most generic sorting tabulate data. It works for every column in database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Sorting tabulate data | |
| * | |
| * @param $column | |
| * @param $body | |
| * @return string | |
| */ | |
| function sort_column_by($column, $body) | |
| { | |
| $direction = (request()->get('direction') == 'ASC') ? 'DESC' : 'ASC'; | |
| $route = route(request()->route()->getAction()['as'], ['sortBy' => $column, 'direction' => $direction]); | |
| return "<a title=\"Sort by {$column}\" href=\"{$route}\">{$body}</a>"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment