PaymentRepository::updatePayment()   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 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Adminetic\Website\Repositories;
4
5
use Adminetic\Website\Contracts\PaymentRepositoryInterface;
6
use Adminetic\Website\Http\Requests\PaymentRequest;
7
use Adminetic\Website\Models\Admin\Payment;
8
use Illuminate\Support\Facades\Cache;
9
10
class PaymentRepository implements PaymentRepositoryInterface
11
{
12
    // Payment Index
13
    public function indexPayment()
14
    {
15
        $payments = config('adminetic.caching', true)
16
            ? (Cache::has('payments') ? Cache::get('payments') : Cache::rememberForever('payments', function () {
17
                return Payment::orderBy('position')->get();
18
            }))
19
            : Payment::orderBy('position')->get();
20
21
        return compact('payments');
22
    }
23
24
    // Payment Create
25
    public function createPayment()
26
    {
27
        //
28
    }
29
30
    // Payment Store
31
    public function storePayment(PaymentRequest $request)
32
    {
33
        Payment::create($request->validated());
34
    }
35
36
    // Payment Show
37
    public function showPayment(Payment $payment)
38
    {
39
        return compact('payment');
40
    }
41
42
    // Payment Edit
43
    public function editPayment(Payment $payment)
44
    {
45
        return compact('payment');
46
    }
47
48
    // Payment Update
49
    public function updatePayment(PaymentRequest $request, Payment $payment)
50
    {
51
        $payment->update($request->validated());
52
    }
53
54
    // Payment Destroy
55
    public function destroyPayment(Payment $payment)
56
    {
57
        $payment->delete();
58
    }
59
}
60