Completed
Push — develop-3.0 ( 360277...bd5ff0 )
by Mohamed
06:52
created

TagPolicy::view()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Policies;
13
14
use Illuminate\Auth\Access\HandlesAuthorization;
15
use Tinyissue\Model\Tag;
16
use Tinyissue\Model\User;
17
18
class TagPolicy
19
{
20
    use HandlesAuthorization;
21
22
    /**
23
     * @param User $user
24
     *
25
     * @return bool
26
     */
27
    public function before(User $user)
28
    {
29
        if ($user instanceof User && ($user->isAdmin() || $user->isManager())) {
30
            return true;
31
        }
32
    }
33
34
    /**
35
     * Can view tag.
36
     *
37
     * @param User $user
38
     * @param Tag  $tag
39
     *
40
     * @return bool
41
     */
42
    public function view(User $user, Tag $tag)
43
    {
44
        return $user->role_id >= $tag->role_limit;
45
    }
46
}
47