LocationPolicy::create()   A
last analyzed

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types = 1);
3
4
namespace App\Policies;
5
6
use App\User;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class LocationPolicy
10
{
11
    use HandlesAuthorization;
12
13
    /**
14
     * Determine whether the user can view the location.
15
     *
16
     * @param  \App\User $user
17
     * @return bool
18
     */
19
    public function view(User $user) : bool
20
    {
21
        // Locations can be viewed by administrators and viewers.
22
        return $user->role !== User::ROLE_STUDENT;
23
    }
24
25
    /**
26
     * Determine whether the user can create locations.
27
     *
28
     * @param  \App\User $user
29
     * @return bool
30
     */
31
    public function create(User $user) : bool
32
    {
33
        return $user->role !== User::ROLE_STUDENT;
34
    }
35
36
    /**
37
     * Determine whether the user can update locations.
38
     *
39
     * @param  \App\User $user
40
     * @return bool
41
     */
42
    public function update(User $user) : bool
43
    {
44
        return $user->role !== User::ROLE_STUDENT;
45
    }
46
47
    /**
48
     * Determine whether the user can delete the location.
49
     *
50
     * @param  \App\User $user
51
     * @return bool
52
     */
53
    public function delete(User $user) : bool
54
    {
55
        return $user->role !== User::ROLE_STUDENT;
56
    }
57
58
}
59