AttributeRepository   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A storeAttribute() 0 3 1
A updateAttribute() 0 3 1
A destroyAttribute() 0 3 1
A indexAttribute() 0 9 3
A showAttribute() 0 3 1
A editAttribute() 0 3 1
A createAttribute() 0 2 1
1
<?php
2
3
namespace Adminetic\Website\Repositories;
4
5
use Adminetic\Website\Contracts\AttributeRepositoryInterface;
6
use Adminetic\Website\Http\Requests\AttributeRequest;
7
use Adminetic\Website\Models\Admin\Attribute;
8
use Illuminate\Support\Facades\Cache;
9
10
class AttributeRepository implements AttributeRepositoryInterface
11
{
12
    // Attribute Index
13
    public function indexAttribute()
14
    {
15
        $attributes = config('coderz.caching', true)
16
            ? (Cache::has('attributes') ? Cache::get('attributes') : Cache::rememberForever('attributes', function () {
17
                return Attribute::orderBy('position')->get();
18
            }))
19
            : Attribute::orderBy('position')->get();
20
21
        return compact('attributes');
22
    }
23
24
    // Attribute Create
25
    public function createAttribute()
26
    {
27
        //
28
    }
29
30
    // Attribute Store
31
    public function storeAttribute(AttributeRequest $request)
32
    {
33
        Attribute::create($request->validated());
34
    }
35
36
    // Attribute Show
37
    public function showAttribute(Attribute $attribute)
38
    {
39
        return compact('attribute');
40
    }
41
42
    // Attribute Edit
43
    public function editAttribute(Attribute $attribute)
44
    {
45
        return compact('attribute');
46
    }
47
48
    // Attribute Update
49
    public function updateAttribute(AttributeRequest $request, Attribute $attribute)
50
    {
51
        $attribute->update($request->validated());
52
    }
53
54
    // Attribute Destroy
55
    public function destroyAttribute(Attribute $attribute)
56
    {
57
        $attribute->delete();
58
    }
59
}
60