mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Sort Type List in Eventlog Pages (#12572)
* Sort Type List in Eventlog Pages * update code
This commit is contained in:
@ -28,6 +28,8 @@ use App\Models\Eventlog;
|
||||
|
||||
class EventlogController extends SelectController
|
||||
{
|
||||
protected $default_sort = ['type' => 'asc'];
|
||||
|
||||
/**
|
||||
* Defines validation rules (will override base validation rules for select2 responses too)
|
||||
*
|
||||
@ -41,6 +43,18 @@ class EventlogController extends SelectController
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines sortable fields. The incoming sort field should be the key, the sql column or DB::raw() should be the value
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
protected function sortFields($request)
|
||||
{
|
||||
return ['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines search fields will be searched in order
|
||||
*
|
||||
|
@ -52,6 +52,7 @@ abstract class SelectController extends PaginatedAjaxController
|
||||
$limit = $request->get('limit', 50);
|
||||
|
||||
$query = $this->search($request->get('term'), $this->baseQuery($request), $this->searchFields($request));
|
||||
$this->sort($request, $query);
|
||||
$paginator = $query->simplePaginate($limit);
|
||||
|
||||
return $this->formatResponse($paginator);
|
||||
|
Reference in New Issue
Block a user