Completed
Push — master ( e5ba92...7a1e6c )
by Arjay
13:54
created

EloquentRepository::getModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Yajra\CMS\Repositories\Navigation;
4
5
use Yajra\CMS\Entities\Navigation;
6
use Yajra\CMS\Repositories\RepositoryAbstract;
7
8
class EloquentRepository extends RepositoryAbstract implements Repository
9
{
10
    /**
11
     * Get all published navigation.
12
     *
13
     * @return \Illuminate\Database\Eloquent\Collection|static[]
14
     */
15
    public function getPublished()
16
    {
17
        return $this->getModel()->with([
18
            'menus' => function ($query) {
19
                $query->limitDepth(1)->orderBy('order', 'asc');
20
            },
21
            'menus.permissions',
22
        ])->published()->get();
23
    }
24
25
    /**
26
     * Get repository model.
27
     *
28
     * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder
29
     */
30
    public function getModel()
31
    {
32
        return new Navigation();
33
    }
34
35
    /**
36
     * Find or fail a navigation.
37
     *
38
     * @param int $id
39
     * @return \Yajra\CMS\Entities\Navigation
40
     */
41
    public function findOrFail($id)
42
    {
43
        return $this->getModel()->query()->findOrFail($id);
44
    }
45
}
46