ContactRepository::showContact()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Adminetic\Contact\Repositories;
4
5
use Illuminate\Support\Facades\Cache;
6
use Adminetic\Contact\Models\Admin\Contact;
7
use Adminetic\Contact\Http\Requests\ContactRequest;
8
use Adminetic\Contact\Contracts\ContactRepositoryInterface;
9
10
class ContactRepository implements ContactRepositoryInterface
11
{
12
    // Contact Index
13
    public function indexContact()
14
    {
15
        $contacts = config('coderz.caching', true)
16
            ? (Cache::has('contacts') ? Cache::get('contacts') : Cache::rememberForever('contacts', function () {
17
                return Contact::latest()->paginate(10);
18
            }))
19
            : Contact::latest()->paginate(10);
20
        return compact('contacts');
21
    }
22
23
    // Contact Create
24
    public function createContact()
25
    {
26
        //
27
    }
28
29
    // Contact Store
30
    public function storeContact(ContactRequest $request)
31
    {
32
        Contact::create($request->validated());
33
    }
34
35
    // Contact Show
36
    public function showContact(Contact $contact)
37
    {
38
        return compact('contact');
39
    }
40
41
    // Contact Edit
42
    public function editContact(Contact $contact)
43
    {
44
        return compact('contact');
45
    }
46
47
    // Contact Update
48
    public function updateContact(ContactRequest $request, Contact $contact)
49
    {
50
        $contact->update($request->validated());
51
    }
52
53
    // Contact Destroy
54
    public function destroyContact(Contact $contact)
55
    {
56
        $contact->delete();
57
    }
58
}
59