Passed
Push — develop ( 6dcea6...5ae9a6 )
by Septianata
16:24
created

User::getIssuerFullname()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Models;
4
5
use App\Enum\Gender;
6
use App\Infrastructure\Foundation\Auth\User as Authenticatable;
7
use App\Models\Contracts\HasTelegramChatId;
8
use App\Models\Contracts\Issuerable;
9
use App\Notifications\ResetPasswordQueued;
10
use App\Notifications\VerifyEmailQueued;
11
use Illuminate\Contracts\Auth\MustVerifyEmail;
12
use Illuminate\Database\Eloquent\Collection;
13
use Illuminate\Database\Eloquent\Factories\HasFactory;
14
use Illuminate\Notifications\Notifiable;
15
use Propaganistas\LaravelPhone\Casts\E164PhoneNumberCast;
16
17
class User extends Authenticatable implements MustVerifyEmail, Issuerable, HasTelegramChatId
18
{
19
    use HasFactory, Notifiable,
0 ignored issues
show
Bug introduced by
The trait App\Models\Concerns\User\Attribute requires the property $name which is not provided by App\Models\User.
Loading history...
introduced by
The trait App\Models\Concerns\User\Relation requires some properties which are not provided by App\Models\User: $name, $map, $permissions, $guard_name
Loading history...
Bug introduced by
The trait App\Models\Concerns\User\Event requires the property $map which is not provided by App\Models\User.
Loading history...
20
        Concerns\User\Attribute,
21
        Concerns\User\Event,
22
        Concerns\User\Relation;
23
24
    /**
25
     * {@inheritDoc}
26
     */
27
    protected $fillable = [
28
        'telegram_chat_id',
29
        'username',
30
        'fullname',
31
        'gender',
32
        'email',
33
        'phone_country',
34
        'phone',
35
        'password',
36
        'is_active',
37
    ];
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    protected $hidden = [
43
        'password',
44
        'remember_token',
45
    ];
46
47
    /**
48
     * {@inheritDoc}
49
     */
50
    protected $casts = [
51
        'gender' => Gender::class,
52
        'phone' => E164PhoneNumberCast::class,
53
        'email_verified_at' => 'datetime',
54
        'is_active' => 'boolean',
55
    ];
56
57
    /**
58
     * {@inheritDoc}
59
     */
60
    public function getTelegramChatId(): string
61
    {
62
        return $this->telegram_chat_id;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->telegram_chat_id could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
63
    }
64
65
    /**
66
     * {@inheritDoc}
67
     */
68 3
    public function sendEmailVerificationNotification()
69
    {
70 3
        $this->notify(new VerifyEmailQueued);
71 3
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76 3
    public function sendPasswordResetNotification($token)
77
    {
78 3
        $this->notify(new ResetPasswordQueued($token));
79 3
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public function getIssuerFullname(): string
85
    {
86
        return $this->fullname;
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92
    public function getIssuerRole(): string
93
    {
94
        return trans('admin-lang.user');
0 ignored issues
show
Bug Best Practice introduced by
The expression return trans('admin-lang.user') could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
95
    }
96
97
    /**
98
     * {@inheritDoc}
99
     */
100
    public function getIssuerUrl(): string
101
    {
102
        return route('admin.user.show', $this);
103
    }
104
105
    /**
106
     * Return collection of model instance data where role is "admin".
107
     *
108
     * @param  array|string  $columns
109
     * @return \Illuminate\Database\Eloquent\Collection<static>
110
     */
111
    public static function getAdmin($columns = ['*']): Collection
112
    {
113
        return static::role(Role::ROLE_ADMIN)->get($columns);
114
    }
115
}
116