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 — development ( f5a703...65354c )
by José
03:44
created

User::getRouteKeyName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace DoeSangue\Models;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Foundation\Auth\User as Authenticatable;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
use DoeSangue\Models\Campaign;
9
use DoeSangue\Models\Invite;
10
use DoeSangue\Models\BloodType;
11
use DoeSangue\Models\Comment;
12
13
class User extends Authenticatable
14
{
15
    use Notifiable, SoftDeletes;
16
17
    /**
18
     * The attributes that are mass assignable.
19
     *
20
     * @var array
21
     */
22
    protected $fillable =
23
      [
24
        'first_name',
25
        'last_name',
26
        'email',
27
        'username',
28
        'phone',
29
        'country_code',
30
        'bio',
31
        'birthdate',
32
        'active',
33
        'password',
34
        'blood_type_id',
35
        ];
36
37
    /**
38
     * The attributes that should be hidden for arrays.
39
     *
40
     * @var array
41
     */
42
    protected $hidden =
43
        [
44
          'password',
45
          'remember_token',
46
          'created_at',
47
          'updated_at',
48
          'deleted_at',
49
          'id',
50
          'phone',
51
          'active',
52
          'username',
53
          'is_active',
54
          'birthdate',
55
          'email',
56
          'blood_type_id'
57
        ];
58
59
    /**
60
     * The dates attributes.
61
     *
62
     * @var array $dates
63
     */
64
    protected $dates =
65
      [
66
        'created_at',
67
        'updated_at',
68
        'deleted_at'
69
      ];
70
71
    protected $appends =
72
      [
73
        'is_active'
74
      ];
75
76
    /**
77
     * Returns the full name of user.
78
     *
79
     * @return string
80
     */
81
    public function getFullNameAttribute($value)
82
    {
83
        return ucfirst($this->first_name).' '.ucfirst($this->last_name);
84
    }
85
86
    /**
87
     * Get user avatar or set default.png as default.
88
     *
89
     * @return void
90
     */
91
    public function getAvatarAttribute($avatar)
92
    {
93
        return asset($avatar ?: 'images/avatars/default.png');
94
    }
95
96
    /**
97
     * Returns the campaigns created by the user.
98
     *
99
     * @return array relationship
100
     * @var    array
101
     */
102
    public function campaigns()
103
    {
104
        return $this->hasMany(Campaign::class);
105
    }
106
107
    /**
108
     * Related.
109
     *
110
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
111
     */
112
    public function bloodType()
113
    {
114
        return $this->belongsTo(BloodType::class, 'blood_type_id');
115
    }
116
117
    /**
118
     * Return as Many invites created by user.
119
     */
120
    public function invites()
121
    {
122
        return $this->hasMany(Invite::class);
123
    }
124
125
    /**
126
     * Returns the comments created by the user.
127
     *
128
     * @return array relationship
129
     * @var    array
130
     */
131
    public function comments()
132
    {
133
        return $this->hasMany(Comment::class);
134
    }
135
136
    public function getIsActiveAttribute()
137
    {
138
        return $this->attributes[ 'status' ] == "active";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal active does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
139
    }
140
141
    /**
142
     * Get the route key for the model.
143
     *
144
     * @return string
145
     */
146
    public function getRouteKeyName()
147
    {
148
        return 'username';
149
    }
150
151
    /**
152
     * Get the user phone number
153
     * @return string
154
     */
155
    public function getPhoneNumberAttribute()
156
    {
157
        return $this->attributes[ 'country_code' ].$this->attributes[ 'phone' ];
158
    }
159
160
    /**
161
     * Return the user fullname
162
     * @return string
163
     */
164
    public function getPhoneFullNameAttribute()
165
    {
166
        return $this->attributes[ 'first_name' ]. $this->attributes[ 'last_name' ];
167
    }
168
}
169