diff options
Diffstat (limited to 'api/Users/Repositories/UserRepository.php')
-rw-r--r-- | api/Users/Repositories/UserRepository.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/api/Users/Repositories/UserRepository.php b/api/Users/Repositories/UserRepository.php new file mode 100644 index 0000000..68416df --- /dev/null +++ b/api/Users/Repositories/UserRepository.php @@ -0,0 +1,35 @@ +<?php + +namespace Api\Users\Repositories; + +use Api\Users\Models\User; +use Infrastructure\Database\Eloquent\Repository; + +class UserRepository extends Repository +{ + public function getModel() + { + return new User(); + } + + public function create(array $data) + { + $user = $this->getModel(); + + $data['password'] = password_hash($data['password'], PASSWORD_BCRYPT); + + $user->fill($data); + $user->save(); + + return $user; + } + + public function update(User $user, array $data) + { + $user->fill($data); + + $user->save(); + + return $user; + } +} |