SubscriptionPolicy::view()   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 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\User;
6
use App\Models\Subscription;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class SubscriptionPolicy
10
{
11
    use HandlesAuthorization;
12
13
    /**
14
     * Determine whether the user can view the subscription.
15
     *
16
     * @param  \App\Models\User $user
17
     * @param Subscription $subscription
18
     * @return mixed
19
     */
20
    public function view(User $user, Subscription $subscription)
21
    {
22
        return $user->id === $subscription->user_id;
23
    }
24
25
    /**
26
     * Determine whether the user can update the subscription.
27
     *
28
     * @param  \App\Models\User $user
29
     * @param Subscription $subscription
30
     * @return mixed
31
     */
32
    public function update(User $user, Subscription $subscription)
33
    {
34
        return $user->id === $subscription->user_id;
35
    }
36
37
    /**
38
     * Determine whether the user can delete the subscription.
39
     *
40
     * @param  \App\Models\User $user
41
     * @param Subscription $subscription
42
     * @return mixed
43
     */
44
    public function delete(User $user, Subscription $subscription)
45
    {
46
        return $user->id === $subscription->user_id;
47
    }
48
}
49