aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/Posts/Repositories/PostRepository.php
blob: 9954af935bf6fa0c0ffb4c469dd951df0ef447e1 (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
<?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();

        $post->fill($data);
        $post->save();

        return $post;
    }

    public function update(Post $post, array $data)
    {
        $post->fill($data);

        $post->save();

        return $post;
    }
}