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

Passed
Pull Request — development (#48)
by José
06:51
created

User::getRouteKeyName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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
        'bio',
30
        'birthdate',
31
        'active',
32
        'password',
33
        'blood_type_id',
34
        ];
35
36
    /**
37
     * The attributes that should be hidden for arrays.
38
     *
39
     * @var array
40
     */
41
    protected $hidden =
42
        [
43
          'password',
44
          'remember_token',
45
          'created_at',
46
          'updated_at',
47
          'deleted_at',
48
          'id',
49
          'phone',
50
          'active',
51
          'username',
52
          'is_active',
53
          'birthdate',
54
          'email',
55
          'blood_type_id'
56
        ];
57
58
    /**
59
     * The dates attributes.
60
     *
61
     * @var array $dates
62
     */
63
    protected $dates =
64
      [
65
        'created_at',
66
        'updated_at',
67
        'deleted_at'
68
      ];
69
70
    protected $appends =
71
      [
72
        'is_active'
73
      ];
74
75
    /**
76
     * Returns the full name of user.
77
     *
78
     * @return string
79
     */
80
    public function getFullNameAttribute($value)
81
    {
82
        return ucfirst($this->first_name).' '.ucfirst($this->last_name);
83
    }
84
85
    /**
86
     * Get user avatar or set default.png as default.
87
     *
88
     * @return void
89
     */
90
    public function getAvatarAttribute($avatar)
91
    {
92
        return asset($avatar ?: 'images/avatars/default.png');
93
    }
94
95
    /**
96
     * Returns the campaigns created by the user.
97
     *
98
     * @return array relationship
99
     * @var    array
100
     */
101
    public function campaigns()
102
    {
103
        return $this->hasMany(Campaign::class);
104
    }
105
106
    /**
107
     * Related.
108
     *
109
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
110
     */
111
    public function bloodType()
112
    {
113
        return $this->belongsTo(BloodType::class, 'blood_type_id');
114
    }
115
116
    /**
117
     * Return as Many invites created by user.
118
     */
119
    public function invites()
120
    {
121
        return $this->hasMany(Invite::class);
122
    }
123
124
    /**
125
     * Returns the comments created by the user.
126
     *
127
     * @return array relationship
128
     * @var    array
129
     */
130
    public function comments()
131
    {
132
        return $this->hasMany(Comment::class);
133
    }
134
135
    public function getIsActiveAttribute()
136
    {
137
        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...
138
    }
139
140
    /**
141
     * Get the route key for the model.
142
     *
143
     * @return string
144
     */
145
    public function getRouteKeyName()
146
    {
147
        return 'username';
148
    }
149
}
150