| @@ 78-91 (lines=14) @@ | ||
| 75 | * @return array |
|
| 76 | * @throws \Exception |
|
| 77 | */ |
|
| 78 | public function searchUsers($str) |
|
| 79 | { |
|
| 80 | $repo = new UserRepository; |
|
| 81 | $stmt = $this->database->prepare($repo->searchUsersQuery()); |
|
| 82 | $name = '%' . $str . '%'; |
|
| 83 | $stmt->bindParam('name', $name); |
|
| 84 | $stmt->execute(); |
|
| 85 | $users = $stmt->fetchAll(); |
|
| 86 | if (!$users) { |
|
| 87 | throw new \Exception(MessageService::USER_NAME_NOT_FOUND, 404); |
|
| 88 | } |
|
| 89 | ||
| 90 | return $users; |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Create a user. |
|
| @@ 62-75 (lines=14) @@ | ||
| 59 | * @return array |
|
| 60 | * @throws \Exception |
|
| 61 | */ |
|
| 62 | public function searchTasks($tasksName) |
|
| 63 | { |
|
| 64 | $query = $this->searchTasksQuery(); |
|
| 65 | $statement = $this->database->prepare($query); |
|
| 66 | $query = '%' . $tasksName . '%'; |
|
| 67 | $statement->bindParam('query', $query); |
|
| 68 | $statement->execute(); |
|
| 69 | $tasks = $statement->fetchAll(); |
|
| 70 | if (!$tasks) { |
|
| 71 | throw new \Exception(MessageService::TASK_NOT_FOUND, 404); |
|
| 72 | } |
|
| 73 | ||
| 74 | return $tasks; |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * Create a task. |
|