FaqRepository   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

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

7 Methods

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