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