Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
CustomerPolicy
n/a
0 / 0
n/a
0 / 0
6
n/a
0 / 0
 view
n/a
0 / 0
n/a
0 / 0
1
 viewAny
n/a
0 / 0
n/a
0 / 0
1
 create
n/a
0 / 0
n/a
0 / 0
1
 update
n/a
0 / 0
n/a
0 / 0
1
 delete
n/a
0 / 0
n/a
0 / 0
1
 customerBelongsToService
n/a
0 / 0
n/a
0 / 0
1
1<?php
2
3namespace App\Policies;
4
5use App\Models\Customer;
6use App\Models\Service;
7use Illuminate\Auth\Access\HandlesAuthorization;
8use App\Policies\Rules\UserStaticRules as USR;
9
10/**
11 * @codeCoverageIgnore
12 */
13class CustomerPolicy
14{
15    use HandlesAuthorization;
16
17    /**
18     * View a Customer.
19     *
20     * @return boolean
21     */
22    public function view(): bool
23    {
24        return USR::everyOne();
25    }
26
27    /**
28     * View any a Customer.
29     *
30     * @return boolean
31     */
32    public function viewAny(): bool
33    {
34        return USR::everyOne();
35    }
36
37    /**
38     * Create a Customer.
39     *
40     * @return boolean
41     */
42    public function create(): bool
43    {
44        return USR::noOne();
45    }
46
47    /**
48     * Update a Customer.
49     *
50     * @return boolean
51     */
52    public function update(): bool
53    {
54        return USR::noOne();
55    }
56
57    /**
58     * Delete a Customer.
59     *
60     * @return boolean
61     */
62    public function delete(): bool
63    {
64        return USR::everyOne();
65    }
66
67    /**
68     * Check if the customer belongs to the service
69     *
70     * @param \App\Models\Service  $service
71     * @param \App\Models\Customer $customer
72     * @return boolean
73     */
74    public function customerBelongsToService(Service $service, Customer $customer)
75    {
76        return !\is_null($customer->login($service->brand));
77    }
78}