TechTipCommentPolicy   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 7
c 2
b 0
f 0
dl 0
loc 32
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A manage() 0 3 1
A update() 0 3 2
A create() 0 3 1
A delete() 0 3 2
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\User;
6
use App\Models\TechTipComment;
7
8
use App\Traits\AllowTrait;
9
use Illuminate\Auth\Access\HandlesAuthorization;
10
11
class TechTipCommentPolicy
12
{
13
    use AllowTrait;
14
    use HandlesAuthorization;
15
16
    public function manage(User $user)
17
    {
18
        return $this->checkPermission($user, 'Manage Tech Tips');
19
    }
20
21
    /**
22
     * Determine whether the user can create models
23
     */
24
    public function create(User $user)
25
    {
26
        return $this->checkPermission($user, 'Comment on Tech Tip');
27
    }
28
29
    /**
30
     * Determine whether the user can update the model
31
     */
32
    public function update(User $user, TechTipComment $techTipComment)
33
    {
34
        return $user->user_id == $techTipComment->user_id || $this->checkPermission($user, 'Manage Tech Tips');
35
    }
36
37
    /**
38
     * Determine whether the user can delete the model
39
     */
40
    public function delete(User $user, TechTipComment $techTipComment)
41
    {
42
        return $user->user_id == $techTipComment->user_id || $this->checkPermission($user, 'Manage Tech Tips');
43
    }
44
}
45