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