Passed
Push — feature/application-review-ui ( a2990f...389138 )
by Chris
05:33
created

ExperienceSkillPolicy::view()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\ExperienceSkill;
6
use App\Models\User;
7
use App\Policies\BasePolicy;
8
use Illuminate\Auth\Access\HandlesAuthorization;
9
10
class ExperienceSkillPolicy extends BasePolicy
11
{
12
    use HandlesAuthorization;
13
14
    /**
15
     * Determine whether the user can view the ExperienceSkill object.
16
     *
17
     * @param  \App\Models\User  $user
18
     * @param  ExperienceSkill $experienceSkill
19
     * @return mixed
20
     */
21
    public function view(User $user, $experienceSkill)
22
    {
23
        return $user->can('view', $experienceSkill->experience);
24
    }
25
26
    /**
27
     * Determine whether the user can create ExperienceSkill.
28
     *
29
     * @param  \App\Models\User  $user
30
     * @return mixed
31
     */
32
    public function create(User $user)
33
    {
34
        return $user->isApplicant();
35
    }
36
37
    /**
38
     * Determine whether the user can update the ExperienceSkill object.
39
     *
40
     * @param  \App\Models\User  $user
41
     * @param  ExperienceSkill $experienceSkill
42
     * @return mixed
43
     */
44
    public function update(User $user, $experienceSkill)
45
    {
46
        return $user->can('update', $experienceSkill->experience);
47
    }
48
49
    /**
50
     * Determine whether the user can delete the ExperienceSkill.
51
     *
52
     * @param  \App\Models\User  $user
53
     * @param  ExperienceSkill $experienceSkill@return mixed
54
     */
55
    public function delete(User $user, $experienceSkill)
56
    {
57
        // Note that this only requires the user to have UPDATE permissions for the associated experience, not DELETE.
58
        return $user->can('update', $experienceSkill->experience);
59
    }
60
}
61