Last active
August 29, 2015 14:04
-
-
Save kamaulynder/93b7b0ff1c15d880e011 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // TagRepository | |
| public function search(TagSearchData $search, Array $params = null) | |
| { | |
| $where = Arr::extract($search->asArray(), ['tag', 'type','role']); | |
| if ($search->parent) { | |
| $where['parent_id'] = $search->parent; | |
| } | |
| if ($search->role) { | |
| $where['role'] = $search->role; | |
| } | |
| // Start the query, removing empty values | |
| $query = $this->selectQuery(array_filter($where)); | |
| if ($search->q) { | |
| // Tag text searching | |
| $query->where('tag', 'LIKE', "%{$search->q}%"); | |
| } | |
| if (!empty($params['orderby'])) { | |
| $query->order_by($params['orderby'], Arr::get($params, 'order')); | |
| } | |
| if (!empty($params['offset'])) { | |
| $query->offset($params['offset']); | |
| } | |
| if (!empty($params['limit'])) { | |
| $query->limit($params['limit']); | |
| } | |
| $results = $query->execute($this->db); | |
| return $this->getCollection($results->as_array()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment