Issues (232)

app/Policies/UserPolicy.php (1 issue)

Severity
1
<?php
2
3
namespace App\Policies;
4
5
use App\User;
6
use Illuminate\Auth\Access\HandlesAuthorization;
7
8
class UserPolicy
9
{
10
    use HandlesAuthorization;
11
12
    /**
13
     * Create a new policy instance.
14
     * @param User $user
15
     * @param $ability
16
     * @return bool
17
     */
18 7
    public function before(User $user, $ability)
0 ignored issues
show
The parameter $ability is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
    public function before(User $user, /** @scrutinizer ignore-unused */ $ability)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20 7
        if ($user->isSuperAdmin()) {
21 3
            return true;
22
        }
23 5
        return null;
24
    }
25
26
    // You can create a user if you are not a simple user
27
    public function create(User $user)
28
    {
29
        if (!$user->isUser()) {
30
            return true;
31
        }
32
        return false;
33
    }
34
35
    // You can store a user if you are not a simple user
36
    public function store(User $user)
37
    {
38
        if (!$user->isUser()) {
39
            return true;
40
        }
41
        return false;
42
    }
43
44
45
    public function delete(User $user, User $userModel)
46
    {
47
        if ($user->isFederationPresident()) {
48
            return $user->federationOwned->id == $userModel->federation_id;
49
        }
50
51
        if ($user->isAssociationPresident()) {
52
            return $user->associationOwned->id == $userModel->association_id;
53
        }
54
        if ($user->isClubPresident()) {
55
            return $user->clubOwned->id == $userModel->club_id;
56
        }
57
        return false;
58
    }
59
60 2
    public function edit(User $user, User $userModel)
61
    {
62
63 2
        if ($user->isUserOrMore()) {
64 2
            return $user->id == $userModel->id;
65
        }
66
        return false;
67
    }
68
69 3
    public function update(User $user, User $userModel)
70
    {
71 3
        if ($user->isUserOrMore()) {
72 3
            return $user->id == $userModel->id;
73
        } 
74
        return false;
75
    }
76
}
77