Passed
Pull Request — master (#48)
by
unknown
06:40
created

FightersGroupPolicy::before()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 6
ccs 0
cts 6
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Policies;
4
5
use App\FightersGroup;
6
use App\Tournament;
7
use App\User;
8
9
class FightersGroupPolicy
10
{
11
//    use HandlesAuthorization;
12
13
    public function before(User $user, $ability)
0 ignored issues
show
Unused Code introduced by
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

13
    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...
14
    {
15
        if ($user->isSuperAdmin()) {
16
            return true;
17
        }
18
        return null;
19
    }
20
21
22
    // You can store a user if you are not a simple user
23
    public function store(User $user, Tournament $tournament)
24
    {
25
        return ($tournament->user_id == $user->id);
26
    }
27
28
29
    public function destroy(User $user, FightersGroup $tree)
30
    {
31
        $tournament = $tree->championship->tournament;
0 ignored issues
show
Bug Best Practice introduced by
The property championship does not exist on App\FightersGroup. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The property tournament does not seem to exist on Illuminate\Database\Eloquent\Relations\Relation.
Loading history...
Bug introduced by
The property tournament does not seem to exist on Illuminate\Database\Eloquent\Builder.
Loading history...
32
//        dd($tournament);
33
        return ($tournament->user_id == $user->id);
0 ignored issues
show
Bug introduced by
The property user_id does not seem to exist on DateTimeZone.
Loading history...
34
35
    }
36
37
38
}
39