Completed
Push — master ( 03bc6f...00f77b )
by Arjay
11:37
created

EloquentRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A all() 0 4 1
A getByName() 0 11 2
1
<?php
2
3
namespace Yajra\CMS\Repositories\FileAsset;
4
5
use Yajra\CMS\Entities\FileAsset;
6
use Yajra\CMS\Repositories\RepositoryAbstract;
7
8
/**
9
 * Class FileAssetEloquentRepository
10
 *
11
 * @package Yajra\CMS\Repositories\Article
12
 */
13
class EloquentRepository extends RepositoryAbstract implements Repository
14
{
15
    /**
16
     * Get repository model.
17
     *
18
     * @return \Yajra\CMS\Entities\FileAsset
19
     */
20
    public function getModel()
21
    {
22
        return new FileAsset();
23
    }
24
25
    /**
26
     * Get all file assets.
27
     *
28
     * @return \Illuminate\Database\Eloquent\Collection|static[]
29
     */
30
    public function all()
31
    {
32
        return $this->getModel()->query()->get();
33
    }
34
35
    /**
36
     * Get file asset by name.
37
     *
38
     * @param string $name
39
     * @param null $category
40
     * @return \Yajra\CMS\Entities\FileAsset
41
     */
42
    public function getByName($name, $category = null)
43
    {
44
        if (is_null($category)) {
45
            $category = config('asset.default');
46
        }
47
48
        return $this->getModel()
49
                    ->where('name', $name)
50
                    ->where('category', $category)
51
                    ->first();
52
    }
53
}