cleanup
This commit is contained in:
committed by
marco
parent
5b93e1c8a6
commit
097b638e6b
@ -13,7 +13,26 @@ class Subscribers {
|
||||
$data = $_POST['data'];
|
||||
$offset = (isset($data['offset']) ? (int)$data['offset'] : 0);
|
||||
$limit = (isset($data['limit']) ? (int)$data['limit'] : 50);
|
||||
$collection = Subscriber::offset($offset)->limit($limit)->find_array();
|
||||
$search = (isset($data['search']) ? $data['search'] : null);
|
||||
$sort_by = (isset($data['sort_by']) ? $data['sort_by'] : 'id');
|
||||
$sort_order = (isset($data['sort_order']) ? $data['sort_order'] : 'desc');
|
||||
|
||||
$collection = Subscriber::{'order_by_'.$sort_order}($sort_by);
|
||||
|
||||
if($search !== null) {
|
||||
$collection->where_raw(
|
||||
'(`email` LIKE ? OR `first_name` LIKE ? OR `last_name` LIKE ?)',
|
||||
array('%'.$search.'%', '%'.$search.'%', '%'.$search.'%')
|
||||
);
|
||||
}
|
||||
|
||||
$collection = array(
|
||||
'count' => $collection->count(),
|
||||
'items' => $collection
|
||||
->offset($offset)
|
||||
->limit($limit)
|
||||
->find_array()
|
||||
);
|
||||
} else {
|
||||
$collection = Subscriber::find_array();
|
||||
}
|
||||
|
Reference in New Issue
Block a user