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
Push — master ( 5df57d...5c7169 )
by Mark
02:17
created

Page::generateMenuUrl()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Model;
4
5
use Carbon\Carbon;
6
use OwenIt\Auditing\Auditable;
7
use App\Classes\Interfaces\AuditInterface;
8
use Illuminate\Database\Eloquent\SoftDeletes;
9
use Illuminate\Database\Eloquent\Relations\BelongsTo;
10
use Illuminate\Database\Eloquent\Model as EloquentModel;
11
12
/**
13
 * Class Pages.
14
 *
15
 * @property Account getPublisher
16
 * @property Redirect redirect
17
 * @property Menu $menu
18
 *
19
 * @property int $id
20
 * @property string $slug
21
 * @property string $content
22
 * @property string $banner
23
 * @property string $seo_title
24
 * @property string $seo_description
25
 * @property string $seo_keywords
26
 * @property int $views
27
 * @property bool $sitemap
28
 * @property bool $enabled
29
 * @property string $plugin
30
 * @property int $editable
31
 * @property int $creator_id
32
 * @property int $editor_id
33
 *
34
 * @property Carbon $deleted_at
35
 * @property Carbon $created_at
36
 * @property Carbon $updated_at
37
 */
38
class Page extends EloquentModel implements AuditInterface
39
{
40
    /*
41
     * Laravel Deleting.
42
     * @ https://laravel.com/docs/5.5/eloquent#soft-deleting
43
     */
44
    use SoftDeletes;
45
    /*
46
     * Laravel Audits.
47
     * @ http://www.laravel-auditing.com
48
     */
49
    use Auditable;
50
51
    /**
52
     * The table associated with the model.
53
     *
54
     * @var string
55
     */
56
    protected $table = 'pages';
57
58
    /**
59
     * The attributes that are mass assignable.
60
     *
61
     * @var array
62
     */
63
    protected $fillable = ['seo_title', 'slug'];
64
65
    /**
66
     * The table date columns, casted to Carbon.
67
     *
68
     * @var array
69
     */
70
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
71
72
    /**
73
     * Attributes to exclude from the Audit.
74
     *
75
     * @var array
76
     */
77
    protected $auditExclude = [
78
        'views',
79
    ];
80
81
    /**
82
     * Increment the view count of the page.
83
     *
84
     * @return int
85
     */
86
    public function incrementViews()
87
    {
88
        return $this->views = $this->views + 1;
89
    }
90
91
    /**
92
     * A page belongs to a single menu.
93
     *
94
     * @return Menu|BelongsTo
95
     */
96
    public function menu()
97
    {
98
        return $this->belongsTo(Menu::class, 'id', 'page_id');
99
    }
100
101
    /**
102
     * A page can have a redirect to another url, external or internal.
103
     *
104
     * @return Redirect|\Illuminate\Database\Eloquent\Relations\HasOne
105
     */
106
    public function redirect()
107
    {
108
        return $this->hasOne(Redirect::class, 'from', 'id');
109
    }
110
111
    /**
112
     * Get the creator model of the eloquent model.
113
     *
114
     * @return Account|\Illuminate\Database\Eloquent\Relations\BelongsTo
115
     */
116
    public function creator()
117
    {
118
        return $this->belongsTo(Account::class, 'creator_id', 'id');
119
    }
120
121
    /**
122
     * Get the creator model of the eloquent model.
123
     *
124
     * @return Account|\Illuminate\Database\Eloquent\Relations\BelongsTo
125
     */
126
    public function editor()
127
    {
128
        return $this->belongsTo(Account::class, 'editor_id', 'id');
129
    }
130
131
    /**
132
     * Generate a link for the audit log.
133
     *
134
     * @return string
135
     */
136
    public function auditTitle()
137
    {
138
        return $this->seo_title;
139
    }
140
141
    /**
142
     * Generate a url to the audited data.
143
     *
144
     * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
145
     */
146
    public function auditUrl()
147
    {
148
        return route('admin.pages.edit', $this->slug);
0 ignored issues
show
Documentation introduced by
$this->slug is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
149
    }
150
151
    /**
152
     * Generate a url slug based on the relationship this belongs to.
153
     *
154
     * @return string
155
     */
156
    public function slug()
157
    {
158
        if ($this->menu && $this->menu->parent) {
159
            if ($this->menu->parent->page->slug != 'index') {
160
                return sprintf('%s/%s', strtolower($this->menu->parent->title), $this->slug);
161
            }
162
        }
163
164
        return $this->slug;
165
    }
166
}
167