Issues (232)

app/Federation.php (4 issues)

1
<?php
2
3
namespace App;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Illuminate\Database\Eloquent\Model;
7
8
class Federation extends Model
9
{
10
11
    public $timestamps = true;
12
    protected $table = 'federation';
13
    protected $guarded = ['id'];
14
15 3
    public static function fillSelect()
16
    {
17
        // User is SuperAdmin
18 3
        $federations = Federation::pluck('name', 'id')->prepend('-', 0);
19 3
        return $federations;
20
    }
21
22
    public static function fillSelectForVueJs($user)
0 ignored issues
show
The parameter $user 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

22
    public static function fillSelectForVueJs(/** @scrutinizer ignore-unused */ $user)

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...
23
    {
24
        // User is SuperAdmin
25
        $federations = Federation::get(['id as value', 'name as text']);
26
        return $federations;
27
    }
28
29 1
    public function president()
30
    {
31 1
        return $this->hasOne(User::class, 'id', 'president_id');
32
    }
33
34
    public function associations()
35
    {
36
        return $this->hasMany(Association::Class);
0 ignored issues
show
The constant App\Association::Class was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37
    }
38
39
    public function clubs()
40
    {
41
        return $this->hasManyThrough(Club::class, Association::class);
42
    }
43
44 1
    public function country()
45
    {
46 1
        return $this->belongsTo(Country::Class);
0 ignored issues
show
The constant App\Country::Class was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
47
    }
48
49
    /**
50
     * @param $query
51
     * @param User $user
52
     * @return Builder
0 ignored issues
show
The type App\Builder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
53
     * @throws AuthorizationException
54
     */
55 1
    public function scopeForUser($query, User $user)
56
    {
57
        switch (true) {
58 1
            case $user->isSuperAdmin():
59
                return $query;
60 1
            case $user->isFederationPresident() && $user->federationOwned != null:
61
                return $query->where('id', '=', $user->federationOwned->id);
62
63 1
            case $user->isAssociationPresident() && $user->associationOwned:
64 1
                return $query->where('id', '=', $user->associationOwned->federation->id);
65
66
            case $user->isClubPresident() && $user->clubOwned:
67
                return $query->where('id', '=', $user->clubOwned->association->federation->id);
68
            default:
69
                throw new AuthorizationException();
70
71
        }
72
    }
73
74
75
}