diff options
Diffstat (limited to 'api/Users/Services/UserService.php')
-rw-r--r-- | api/Users/Services/UserService.php | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/api/Users/Services/UserService.php b/api/Users/Services/UserService.php deleted file mode 100644 index 923acd0..0000000 --- a/api/Users/Services/UserService.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -namespace Api\Users\Services; - -use Exception; -use Illuminate\Auth\AuthManager; -use Illuminate\Database\DatabaseManager; -use Illuminate\Events\Dispatcher; -use Api\Users\Exceptions\UserNotFoundException; -use Api\Users\Events\UserWasCreated; -use Api\Users\Events\UserWasDeleted; -use Api\Users\Events\UserWasUpdated; -use Api\Users\Repositories\UserRepository; - -class UserService -{ - private $auth; - - private $database; - - private $dispatcher; - - private $userRepository; - - public function __construct( - AuthManager $auth, - DatabaseManager $database, - Dispatcher $dispatcher, - UserRepository $userRepository - ) { - $this->auth = $auth; - $this->database = $database; - $this->dispatcher = $dispatcher; - $this->userRepository = $userRepository; - } - - public function getAll($options = []) - { - return $this->userRepository->get($options); - } - - public function getById($userId, array $options = []) - { - $user = $this->getRequestedUser($userId); - - return $user; - } - - public function create($data) - { - $user = $this->userRepository->create($data); - - $this->dispatcher->fire(new UserWasCreated($user)); - - return $user; - } - - public function update($userId, array $data) - { - $user = $this->getRequestedUser($userId); - - $this->userRepository->update($user, $data); - - $this->dispatcher->fire(new UserWasUpdated($user)); - - return $user; - } - - public function delete($userId) - { - $user = $this->getRequestedUser($userId); - - $this->userRepository->delete($userId); - - $this->dispatcher->fire(new UserWasDeleted($user)); - } - - private function getRequestedUser($userId) - { - $user = $this->userRepository->getById($userId); - - if (is_null($user)) { - throw new UserNotFoundException(); - } - - return $user; - } -} |