Passed
Push — 5.0.0 ( 757365...6c4e14 )
by Fèvre
05:11
created

BlogCategoryPolicy   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 BlogCategoryPolicy
11
{
12
    use HandlesAuthorization;
13
14
    /**
15
     * Determine whether the user can view all blog categories.
16
     *
17
     * @param User $user
18
     *
19
     * @return bool
20
     */
21
    public function viewAny(User $user): bool
22
    {
23
        return $user->hasPermissionTo('viewAny blog category');
24
    }
25
26
    /**
27
     * Determine whether the user can create a blog category.
28
     *
29
     * @param User $user
30
     *
31
     * @return bool
32
     */
33
    public function create(User $user): bool
34
    {
35
        return $user->hasPermissionTo('create blog category');
36
    }
37
38
    /**
39
     * Determine whether the user can update a blog category.
40
     *
41
     * @param User $user
42
     *
43
     * @return bool
44
     */
45
    public function update(User $user): bool
46
    {
47
        return $user->hasPermissionTo('update blog category');
48
    }
49
50
    /**
51
     * Determine whether the user can delete a blog category.
52
     *
53
     * @param User $user
54
     *
55
     * @return bool
56
     */
57
    public function delete(User $user): bool
58
    {
59
        return $user->hasPermissionTo('delete blog category');
60
    }
61
}
62