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 ( 70e47f...dda101 )
by Mark
07:55
created

Page::setTitleAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Model;
4
5
use Carbon\Carbon;
6
use Illuminate\Support\Collection;
7
use App\Classes\Interfaces\Linkable;
8
use Illuminate\Database\Eloquent\Builder;
9
use Illuminate\Database\Eloquent\SoftDeletes;
10
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11
use Illuminate\Database\Eloquent\Model as EloquentModel;
12
use Laravel\Scout\Searchable;
13
14
/**
15
 * Class Pages.
16
 *
17
 * @property Account getPublisher
18
 * @property Redirect redirect
19
 * @property Menu $menu
20
 *
21
 * @property int $id
22
 * @property string $identifier
23
 * @property string $prefix
24
 * @property string $slug
25
 * @property string $title
26
 * @property string $content
27
 * @property string $banner
28
 * @property string $seo_title
29
 * @property string $seo_description
30
 * @property string $seo_keywords
31
 * @property int $views
32
 * @property bool $sitemap
33
 * @property bool $enabled
34
 * @property string $plugin
35
 * @property bool $editable
36
 * @property bool $special
37
 * @property int $creator_id
38
 * @property int $editor_id
39
 *
40
 * @property Carbon $deleted_at
41
 * @property Carbon $created_at
42
 * @property Carbon $updated_at
43
 *
44
 * @return Page|Collection|Builder
45
 */
46
class Page extends EloquentModel implements Linkable
47
{
48
    /*
49
     * Laravel Deleting.
50
     * @ https://laravel.com/docs/5.5/eloquent#soft-deleting
51
     */
52
    use SoftDeletes;
53
54
    /*
55
     * Laravel Searchable Model.
56
     *
57
     * @ https://laravel.com/docs/5.3/scout#installation
58
     */
59
    use Searchable;
60
61
    /**
62
     * The table associated with the model.
63
     *
64
     * @var string
65
     */
66
    protected $table = 'pages';
67
68
    /**
69
     * The attributes that are not mass assignable.
70
     *
71
     * @var array
72
     */
73
    protected $guarded = [];
74
75
    /**
76
     * The table date columns, casted to Carbon.
77
     *
78
     * @var array
79
     */
80
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
81
82
    /**
83
     * Attributes to exclude from the Audit.
84
     *
85
     * @var array
86
     */
87
    protected $auditExclude = [
88
        'views',
89
    ];
90
91
    /**
92
     * Increment the view count of the page.
93
     *
94
     * @return int
95
     */
96
    public function incrementViews()
97
    {
98
        return $this->views = $this->views + 1;
99
    }
100
101
    /**
102
     * A page belongs to a single menu.
103
     *
104
     * @return Menu|BelongsTo
105
     */
106
    public function menu()
107
    {
108
        return $this->belongsTo(Menu::class, 'id', 'page_id');
109
    }
110
111
    /**
112
     * A page can have a redirect to another url, external or internal.
113
     *
114
     * @return Redirect|\Illuminate\Database\Eloquent\Relations\HasOne
115
     */
116
    public function redirect()
117
    {
118
        return $this->hasOne(Redirect::class, 'from', '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 creator()
127
    {
128
        return $this->belongsTo(Account::class, 'creator_id', 'id');
129
    }
130
131
    /**
132
     * Get the creator model of the eloquent model.
133
     *
134
     * @return Account|\Illuminate\Database\Eloquent\Relations\BelongsTo
135
     */
136
    public function editor()
137
    {
138
        return $this->belongsTo(Account::class, 'editor_id', 'id');
139
    }
140
141
    /**
142
     * @return \Illuminate\Database\Eloquent\Relations\MorphOne|Collection
143
     */
144
    public function link()
145
    {
146
        return $this->morphOne(Link::class, 'from');
147
    }
148
149
    /**
150
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany|Collection
151
     */
152
    public function linked()
153
    {
154
        return $this->morphMany(Link::class, 'to');
155
    }
156
157
    /**
158
     * The url that is used to view this model.
159
     *
160
     * @return string
161
     */
162
    public function route()
163
    {
164
        if ($this->prefix) {
165
            return "{$this->prefix}/{$this->slug}";
166
        }
167
168
        return "{$this->slug}";
169
    }
170
171
    /**
172
     * The name of the current model object.
173
     *
174
     * @return string
175
     */
176
    public function name()
177
    {
178
        return "{$this->seo_title}";
179
    }
180
181
    /**
182
     * @param $value
183
     */
184
    public function setTitleAttribute($value)
185
    {
186
        $this->attributes['seo_title'] = $value;
187
188
        $this->attributes['slug'] = str_slug($value);
189
    }
190
191
}
192