PHP code example of bugloos / query-sorting-bundle
1. Go to this page and download the library: Download bugloos/query-sorting-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bugloos / query-sorting-bundle example snippets
/*
* Sort book by price ascending
*/
//Get api/book/index?order[price]=ASC
OR
$orders = [
'price' => SortType::ASC,
];
/*
* Sort book by price descending
*/
//Get api/book/index?order[price]=DESC
OR
$orders = [
'price' => SortType::DESC,
];
use Bugloos\QuerySortingBundle\Service\QuerySorting;
/*
* Sort book by Country name ascending
*/
//Get api/book/index?order[country]=ASC
OR
$orders = [
'country' => SortType::ASC,
];
/*
* Sort book by Country name descending
*/
//Get api/book/index?order[country]=DESC
OR
$orders = [
'country' => SortType::DESC,
];
/*
* Sort book by Writer age ascending
*/
//Get api/book/index?order[age]=ASC
OR
$orders = [
'age' => SortType::ASC,
];
/*
* Sort book by Writer age descending
*/
//Get api/book/index?order[age]=DESC
OR
$orders = [
'age' => SortType::DESC,
];
/*
* Sort book by title ascending and price descending
*/
//Get api/book/index?order[title]=ASC&order[price]=DESC
OR
$orders = [
'title' => SortType::ASC,
'price' => SortType::DESC,
];