TechTipCommentPolicy::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
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