Completed
Push — master ( 12e65e...324689 )
by Arjay
19:32 queued 04:38
created

FileAssetEloquentRepository::addAsset()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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