@@ 5-50 (lines=46) @@ | ||
2 | ||
3 | use Cartalyst\Support\Traits\RepositoryTrait; |
|
4 | ||
5 | class BlogCategoryRepository implements BlogCategoryRepositoryInterface |
|
6 | { |
|
7 | use RepositoryTrait; |
|
8 | ||
9 | /** |
|
10 | * The Blog category model name. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $model = 'jlourenco\blog\Models\BlogCategory'; |
|
15 | ||
16 | /** |
|
17 | * Create a new blog category repository. |
|
18 | * |
|
19 | * @param string $model |
|
20 | */ |
|
21 | public function __construct($model = null) |
|
22 | { |
|
23 | if (isset($model)) |
|
24 | $this->model = $model; |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * {@inheritDoc} |
|
29 | */ |
|
30 | public function findById($id) |
|
31 | { |
|
32 | return $this |
|
33 | ->createModel() |
|
34 | ->newQuery() |
|
35 | ->find($id); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * {@inheritDoc} |
|
40 | */ |
|
41 | public function findByName($name) |
|
42 | { |
|
43 | return $this |
|
44 | ->createModel() |
|
45 | ->newQuery() |
|
46 | ->where('name', $name) |
|
47 | ->first(); |
|
48 | } |
|
49 | ||
50 | } |
|
51 |
@@ 5-50 (lines=46) @@ | ||
2 | ||
3 | use Cartalyst\Support\Traits\RepositoryTrait; |
|
4 | ||
5 | class BlogPostRepository implements BlogPostRepositoryInterface |
|
6 | { |
|
7 | use RepositoryTrait; |
|
8 | ||
9 | /** |
|
10 | * The Blog post model name. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $model = 'jlourenco\blog\Models\BlogPost'; |
|
15 | ||
16 | /** |
|
17 | * Create a new blog post repository. |
|
18 | * |
|
19 | * @param string $model |
|
20 | */ |
|
21 | public function __construct($model = null) |
|
22 | { |
|
23 | if (isset($model)) |
|
24 | $this->model = $model; |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * {@inheritDoc} |
|
29 | */ |
|
30 | public function findById($id) |
|
31 | { |
|
32 | return $this |
|
33 | ->createModel() |
|
34 | ->newQuery() |
|
35 | ->find($id); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * {@inheritDoc} |
|
40 | */ |
|
41 | public function findByTitle($title) |
|
42 | { |
|
43 | return $this |
|
44 | ->createModel() |
|
45 | ->newQuery() |
|
46 | ->where('title', $title) |
|
47 | ->first(); |
|
48 | } |
|
49 | ||
50 | } |
|
51 |