blob: 671412f7269cc55d25d1024bf588f58534f82df7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
}
}
|