mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
(mvc) add easier model wrapper for default search behavior
This commit is contained in:
parent
3592b64f2c
commit
8a309525e7
@ -49,6 +49,31 @@ class UIModelGrid
|
||||
$this->DataField = $DataField;
|
||||
}
|
||||
|
||||
/**
|
||||
* default model search
|
||||
* @param $request request variable
|
||||
* @param array $fields to collect
|
||||
* @param null|string $defaultSort default sort order
|
||||
* @return array
|
||||
*/
|
||||
public function fetchBindRequest($request, $fields, $defaultSort = null)
|
||||
{
|
||||
$itemsPerPage = $request->get('rowCount', 'int', 9999);
|
||||
$currentPage = $request->get('current', 'int', 1);
|
||||
$sortBy = array($defaultSort);
|
||||
$sortDescending = false;
|
||||
|
||||
if ($request->has('sort') && is_array($request->get("sort"))) {
|
||||
$sortBy = array_keys($request->get("sort"));
|
||||
if ($request->get("sort")[$sortBy[0]] == "desc") {
|
||||
$sortDescending = true;
|
||||
}
|
||||
}
|
||||
|
||||
$searchPhrase = $request->get('searchPhrase', 'string', '');
|
||||
return $this->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch data from Array type field (Base\FieldTypes\ArrayField), sorted by specified fields and optionally filtered
|
||||
* @param array $fields select fieldnames
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user