GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Category   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 68
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3

6 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeRootCategories() 0 4 1
A scopeSubCategories() 0 4 1
A scopeOfUser() 0 4 1
A parentCategory() 0 4 1
A categories() 0 4 1
A defaultForPayees() 0 4 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\SoftDeletes;
6
7
class Category extends Model
8
{
9
    use SoftDeletes;
10
11
    protected $fillable = ['name'];
12
13
    protected $casts = [
14
        'parent_id' => 'integer',
15
    ];
16
17
    /**
18
     * Scope a query to only include sub categories.
19
     *
20
     * @param \Illuminate\Database\Eloquent\Builder $query
21
     *
22
     * @return \Illuminate\Database\Eloquent\Builder
23
     */
24
    public function scopeRootCategories($query)
25
    {
26
        return $query->where('parent_id', null);
27
    }
28
29
    /**
30
     * Scope a query to only include sub categories.
31
     *
32
     * @param \Illuminate\Database\Eloquent\Builder $query
33
     *
34
     * @return \Illuminate\Database\Eloquent\Builder
35
     */
36
    public function scopeSubCategories($query)
37
    {
38
        return $query->whereNotNull('parent_id');
39
    }
40
41
    /**
42
     * Returns categories of the given user.
43
     *
44
     * @param $query
45
     * @param User $user
46
     *
47
     * @return mixed
48
     */
49
    public function scopeOfUser($query, User $user)
50
    {
51
        return $query->where('user_id', $user->id);
52
    }
53
54
    /**
55
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
     */
57
    public function parentCategory()
58
    {
59
        return $this->belongsTo(self::class, 'parent_id');
60
    }
61
62
    /**
63
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
64
     */
65
    public function categories()
66
    {
67
        return $this->hasMany(self::class, 'parent_id');
68
    }
69
70
    public function defaultForPayees()
71
    {
72
        return $this->hasMany(Payee::class, 'last_category_id');
73
    }
74
}
75