Last active
January 29, 2018 07:01
-
-
Save dragg/08c45eedf528b5d1b9849d786d6f04a6 to your computer and use it in GitHub Desktop.
Examples
This file contains 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
/** | |
* Return order field and direction | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
function datatable_get_order_data(\Illuminate\Http\Request $request) | |
{ | |
$columnNumber = $request->get('order')[0]['column']; | |
$column = $request->get('columns')[$columnNumber]; | |
$nameProperty = $column['name']; | |
$direction = $request->get('order')[0]['dir']; | |
return array($nameProperty, $direction); | |
} |
This file contains 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
list($nameProperty, $direction) = datatable_get_order_data($request); | |
$FAQsQuery = FAQ::query(); | |
$FAQsQuery | |
->search($request->get('search')['value']) | |
if ($nameProperty && $direction) { | |
$FAQsQuery->sortBy($nameProperty, $direction); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment