Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#4)
by
unknown
13:18
created

Category::parent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Backpack\NewsCRUD\app\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Backpack\CRUD\CrudTrait;
7
use Cviebrock\EloquentSluggable\SluggableInterface;
8
use Cviebrock\EloquentSluggable\SluggableTrait;
9
10
class Category extends Model implements SluggableInterface
11
{
12
    use CrudTrait;
13
    use SluggableTrait;
14
15
    /*
16
    |--------------------------------------------------------------------------
17
    | GLOBAL VARIABLES
18
    |--------------------------------------------------------------------------
19
    */
20
21
    protected $table = 'categories';
22
    protected $primaryKey = 'id';
23
    // public $timestamps = false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
    // protected $guarded = ['id'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
25
    protected $fillable = ['name', 'parent_id'];
26
    // protected $hidden = [];
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
    // protected $dates = [];
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
    protected $sluggable = [
29
        'build_from' => 'slug_or_name',
30
        'save_to'    => 'slug',
31
        'on_update'  => true,
32
        'unique'     => true,
33
    ];
34
35
    /*
36
    |--------------------------------------------------------------------------
37
    | FUNCTIONS
38
    |--------------------------------------------------------------------------
39
    */
40
41
    /*
42
    |--------------------------------------------------------------------------
43
    | RELATIONS
44
    |--------------------------------------------------------------------------
45
    */
46
47
    public function parent()
48
    {
49
        return $this->belongsTo('Backpack\NewsCRUD\app\Models\Category', 'parent_id');
50
    }
51
52
    public function children()
53
    {
54
        return $this->hasMany('Backpack\NewsCRUD\app\Models\Category', 'parent_id');
55
    }
56
57
    public function articles()
58
    {
59
        return $this->hasMany('Backpack\NewsCRUD\app\Models\Article');
60
    }
61
62
    /*
63
    |--------------------------------------------------------------------------
64
    | SCOPES
65
    |--------------------------------------------------------------------------
66
    */
67
68
    public function scopeFirstLevelItems($query)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
69
    {
70
        return $query->where('depth', '1')
71
                    ->orWhere('depth', null)
72
                    ->orderBy('lft', 'ASC');
73
    }
74
75
    /*
76
    |--------------------------------------------------------------------------
77
    | ACCESORS
78
    |--------------------------------------------------------------------------
79
    */
80
81
    // The slug is created automatically from the "name" field if no slug exists.
82
    public function getSlugOrNameAttribute()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
83
    {
84
        if ($this->slug != '') {
85
            return $this->slug;
86
        }
87
88
        return $this->name;
89
    }
90
91
    /*
92
    |--------------------------------------------------------------------------
93
    | MUTATORS
94
    |--------------------------------------------------------------------------
95
    */
96
}
97