| @@ 80-94 (lines=15) @@ | ||
| 77 | * @return array |
|
| 78 | * @throws \Exception |
|
| 79 | */ |
|
| 80 | public function searchTasks($tasksName) |
|
| 81 | { |
|
| 82 | $repository = new TasksRepository; |
|
| 83 | $query = $repository->searchTasksQuery(); |
|
| 84 | $statement = $this->database->prepare($query); |
|
| 85 | $query = '%' . $tasksName . '%'; |
|
| 86 | $statement->bindParam('query', $query); |
|
| 87 | $statement->execute(); |
|
| 88 | $tasks = $statement->fetchAll(); |
|
| 89 | if (!$tasks) { |
|
| 90 | throw new \Exception(self::TASK_NOT_FOUND, 404); |
|
| 91 | } |
|
| 92 | ||
| 93 | return $tasks; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Create a task. |
|
| @@ 80-94 (lines=15) @@ | ||
| 77 | * @return array |
|
| 78 | * @throws \Exception |
|
| 79 | */ |
|
| 80 | public function searchUsers($str) |
|
| 81 | { |
|
| 82 | $repo = new UsersRepository; |
|
| 83 | $stmt = $this->database->prepare($repo->searchUsersQuery()); |
|
| 84 | $name = '%' . $str . '%'; |
|
| 85 | $stmt->bindParam('name', $name); |
|
| 86 | $stmt->execute(); |
|
| 87 | $users = $stmt->fetchAll(); |
|
| 88 | ||
| 89 | if (!$users) { |
|
| 90 | throw new \Exception(self::USER_NAME_NOT_FOUND, 404); |
|
| 91 | } |
|
| 92 | ||
| 93 | return $users; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Create a user. |
|