FaqRepository::showFaq()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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