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 ( 547e98...0728da )
by Mark
02:25
created

Redirect::toPage()   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 Carbon\Carbon;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use Illuminate\Database\Eloquent\Model as EloquentModel;
8
9
/**
10
 * Class Redirect.
11
 *
12
 * @property int $id
13
 * @property mixed $fromPage
14
 * @property mixed $to
15
 * @property int $creator_id
16
 * @property int $modifier_id
17
 *
18
 * @property Carbon $deleted_at
19
 * @property Carbon $created_at
20
 * @property Carbon $updated_at
21
 */
22
class Redirect extends EloquentModel
23
{
24
25
    /*
26
     * Laravel Deleting.
27
     * @ https://laravel.com/docs/5.5/eloquent#soft-deleting
28
     */
29
    use SoftDeletes;
30
31
    /**
32
     * The table associated with the model.
33
     *
34
     * @var string
35
     */
36
    protected $table = 'redirects';
37
38
    /**
39
     * The table date columns, casted to Carbon.
40
     *
41
     * @var array
42
     */
43
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
44
45
46
47
    public function from()
48
    {
49
        if (is_numeric($this->getAttribute('from'))) {
50
            return makeSlug($this->fromPage);
51
        } else {
52
            return $this->getAttribute('from');
53
        }
54
    }
55
56
    public function setFrom($string)
57
    {
58
        $this->setAttribute('from', $string);
59
60
        return $this;
61
    }
62
63
    public function to()
64
    {
65
        if (is_numeric($this->getAttribute('to'))) {
66
            return makeSlug($this->toPage);
67
        } else {
68
            return $this->getAttribute('to');
69
        }
70
    }
71
72
    public function setTo($string)
73
    {
74
        $this->setAttribute('to', $string);
75
76
        return $this;
77
    }
78
79
    /**
80
     * @param int $integer
81
     * @return $this
82
     */
83
    public function setCreatorID(int $integer)
84
    {
85
        $this->setAttribute('creator_id', $integer);
86
87
        return $this;
88
    }
89
90
    public function creator()
91
    {
92
        return $this->belongsTo(Account::class, 'creator_id', 'id');
93
    }
94
95
    public function modifier()
96
    {
97
        if ($this->getAttribute('modifier_id')) {
98
            return $this->belongsTo(Account::class, 'modifier_id', 'id');
99
        }
100
    }
101
102
    public function deleted_at()
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
103
    {
104
        return $this->getAttribute('deleted_at');
105
    }
106
107
    public function updated_at()
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
108
    {
109
        return $this->getAttribute('updated_at');
110
    }
111
112
    public function created_at()
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
113
    {
114
        return $this->getAttribute('created_at');
115
    }
116
117
    public function isEnabled()
118
    {
119
        return $this->deleted_at() ? false : true;
120
    }
121
122
    public function lastEditor()
123
    {
124
        return $this->modifier() ?: $this->creator();
125
    }
126
127
    /**
128
     * @return Page|mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use \Illuminate\Database\Eloquent\Relations\BelongsTo.

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...
129
     */
130
    public function fromPage()
131
    {
132
        return $this->belongsTo(Page::class, 'from', 'id');
133
    }
134
135
    /**
136
     * @return Page|mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use \Illuminate\Database\Eloquent\Relations\BelongsTo.

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...
137
     */
138
    public function toPage()
139
    {
140
        return $this->belongsTo(Page::class, 'to', 'id');
141
    }
142
}
143