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

EloquentRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 38
rs 10
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPublished() 0 9 1
A getModel() 0 4 1
A findOrFail() 0 4 1
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