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 ( 7fd57f...ddf3cc )
by Mark
02:55
created

Page::link()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Model;
4
5
use App\Classes\Interfaces\Linkable;
6
use Carbon\Carbon;
7
use OwenIt\Auditing\Auditable;
8
use Illuminate\Support\Collection;
9
use Illuminate\Database\Eloquent\Builder;
10
use App\Classes\Interfaces\AuditInterface;
11
use Illuminate\Database\Eloquent\SoftDeletes;
12
use Illuminate\Database\Eloquent\Relations\BelongsTo;
13
use Illuminate\Database\Eloquent\Model as EloquentModel;
14
15
/**
16
 * Class Pages.
17
 *
18
 * @property Account getPublisher
19
 * @property Redirect redirect
20
 * @property Menu $menu
21
 *
22
 * @property int $id
23
 * @property string $prefix
24
 * @property string $slug
25
 * @property string $content
26
 * @property string $banner
27
 * @property string $seo_title
28
 * @property string $seo_description
29
 * @property string $seo_keywords
30
 * @property int $views
31
 * @property bool $sitemap
32
 * @property bool $enabled
33
 * @property string $plugin
34
 * @property int $editable
35
 * @property int $creator_id
36
 * @property int $editor_id
37
 *
38
 * @property Carbon $deleted_at
39
 * @property Carbon $created_at
40
 * @property Carbon $updated_at
41
 *
42
 * @return Page|Collection|Builder
43
 */
44
class Page extends EloquentModel implements Linkable
45
{
46
    /*
47
     * Laravel Deleting.
48
     * @ https://laravel.com/docs/5.5/eloquent#soft-deleting
49
     */
50
    use SoftDeletes;
51
52
    /**
53
     * The table associated with the model.
54
     *
55
     * @var string
56
     */
57
    protected $table = 'pages';
58
59
    /**
60
     * The attributes that are not mass assignable.
61
     *
62
     * @var array
63
     */
64
    protected $guarded = [];
65
66
    /**
67
     * The table date columns, casted to Carbon.
68
     *
69
     * @var array
70
     */
71
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
72
73
    /**
74
     * Attributes to exclude from the Audit.
75
     *
76
     * @var array
77
     */
78
    protected $auditExclude = [
79
        'views',
80
    ];
81
82
    /**
83
     * Increment the view count of the page.
84
     *
85
     * @return int
86
     */
87
    public function incrementViews()
88
    {
89
        return $this->views = $this->views + 1;
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
     * @return \Illuminate\Database\Eloquent\Relations\MorphOne|Collection
133
     */
134
    public function link()
135
    {
136
        return $this->morphOne(Link::class, 'from');
137
    }
138
139
    /**
140
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany|Collection
141
     */
142
    public function linked()
143
    {
144
        return $this->morphMany(Link::class, 'to');
145
    }
146
147
    /**
148
     * The url that is used to view this model.
149
     *
150
     * @return string
151
     */
152
    public function route()
153
    {
154
        if ($this->prefix)
155
            return "{$this->prefix}/{$this->slug}";
156
157
        return "{$this->slug}";
158
    }
159
160
    /**
161
     * The name of the current model object.
162
     *
163
     * @return string
164
     */
165
    public function name()
166
    {
167
        return "{$this->seo_title}";
168
    }
169
}