DashboardRepository::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Anomaly\DashboardModule\Dashboard;
2
3
use Anomaly\DashboardModule\Dashboard\Contract\DashboardInterface;
4
use Anomaly\DashboardModule\Dashboard\Contract\DashboardRepositoryInterface;
5
use Anomaly\Streams\Platform\Entry\EntryRepository;
6
7
/**
8
 * Class DashboardRepository
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class DashboardRepository extends EntryRepository implements DashboardRepositoryInterface
15
{
16
17
    /**
18
     * The entry model.
19
     *
20
     * @var DashboardModel
21
     */
22
    protected $model;
23
24
    /**
25
     * Create a new DashboardRepository instance.
26
     *
27
     * @param DashboardModel $model
28
     */
29
    public function __construct(DashboardModel $model)
30
    {
31
        $this->model = $model;
32
    }
33
34
    /**
35
     * Return only allowed dashboards.
36
     *
37
     * @return DashboardCollection
38
     */
39
    public function allowed()
40
    {
41
        return $this->model->all()->allowed();
42
    }
43
44
    /**
45
     * Find a dashboard by it's slug.
46
     *
47
     * @param $slug
48
     * @return null|DashboardInterface
49
     */
50
    public function findBySlug($slug)
51
    {
52
        return $this->model->where('slug', $slug)->first();
53
    }
54
}
55