Passed
Push — 5.0.0 ( c86c37...f3ec4d )
by Fèvre
06:46
created

SettingPolicy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 3 1
A update() 0 3 1
A create() 0 3 1
A viewAny() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Policies;
6
7
use Xetaravel\Models\User;
8
use Illuminate\Auth\Access\HandlesAuthorization;
9
10
class SettingPolicy
11
{
12
    use HandlesAuthorization;
13
14
    /**
15
     * Determine whether the user can view all settings.
16
     *
17
     * @param User $user
18
     *
19
     * @return bool
20
     */
21
    public function viewAny(User $user): bool
22
    {
23
        return $user->hasPermissionTo('viewAny setting');
24
    }
25
26
    /**
27
     * Determine whether the user can create a setting.
28
     *
29
     * @param User $user
30
     *
31
     * @return bool
32
     */
33
    public function create(User $user): bool
34
    {
35
        return $user->hasPermissionTo('create setting');
36
    }
37
38
    /**
39
     * Determine whether the user can update a setting.
40
     *
41
     * @param User $user
42
     *
43
     * @return bool
44
     */
45
    public function update(User $user): bool
46
    {
47
        return $user->hasPermissionTo('update setting');
48
    }
49
50
    /**
51
     * Determine whether the user can delete a setting.
52
     *
53
     * @param User $user
54
     *
55
     * @return bool
56
     */
57
    public function delete(User $user): bool
58
    {
59
        return $user->hasPermissionTo('delete setting');
60
    }
61
}
62