ExperienceSkillPolicy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
c 0
b 0
f 0
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 3 1
A view() 0 3 1
A create() 0 3 1
A delete() 0 4 1
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
54
     * @return mixed
55
     */
56
    public function delete(User $user, $experienceSkill)
57
    {
58
        // Note that this only requires the user to have UPDATE permissions for the associated experience, not DELETE.
59
        return $user->can('update', $experienceSkill->experience);
60
    }
61
}
62