| 2 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace App\Models;
|
|
|
4 |
|
|
|
5 |
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
6 |
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
7 |
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
8 |
use Illuminate\Notifications\Notifiable;
|
|
|
9 |
use Laravel\Sanctum\HasApiTokens;
|
|
|
10 |
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
11 |
|
| 415 |
lars |
12 |
/**
|
|
|
13 |
* App\Models\User
|
|
|
14 |
*
|
|
|
15 |
* @property int $id
|
|
|
16 |
* @property string $name
|
|
|
17 |
* @property string $email
|
|
|
18 |
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
|
|
19 |
* @property string $password
|
|
|
20 |
* @property string $remember_token
|
|
|
21 |
* @property string $created_by
|
|
|
22 |
* @property string $updated_by
|
|
|
23 |
* @property \Illuminate\Support\Carbon|null $created_at
|
|
|
24 |
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
|
25 |
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
|
|
26 |
* @property-read int|null $notifications_count
|
|
|
27 |
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
|
|
|
28 |
* @property-read int|null $tokens_count
|
|
|
29 |
* @method static \Database\Factories\UserFactory factory($count = null, $state = [])
|
|
|
30 |
* @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
|
|
|
31 |
* @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
|
|
|
32 |
* @method static \Illuminate\Database\Eloquent\Builder|User query()
|
|
|
33 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
|
|
|
34 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedBy($value)
|
|
|
35 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmail($value)
|
|
|
36 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmailVerifiedAt($value)
|
|
|
37 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereId($value)
|
|
|
38 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereName($value)
|
|
|
39 |
* @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
|
|
|
40 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereRememberToken($value)
|
|
|
41 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
|
|
|
42 |
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedBy($value)
|
|
|
43 |
* @mixin \Eloquent
|
|
|
44 |
*/
|
|
|
45 |
class User extends Authenticatable
|
| 2 |
lars |
46 |
{
|
|
|
47 |
use HasApiTokens, HasFactory, Notifiable;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* The attributes that are mass assignable.
|
|
|
51 |
*
|
|
|
52 |
* @var array<int, string>
|
|
|
53 |
*/
|
|
|
54 |
protected $fillable = [
|
|
|
55 |
'name',
|
|
|
56 |
'email',
|
|
|
57 |
'password',
|
|
|
58 |
'google2fa_secret',
|
|
|
59 |
];
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* The attributes that should be hidden for serialization.
|
|
|
63 |
*
|
|
|
64 |
* @var array<int, string>
|
|
|
65 |
*/
|
|
|
66 |
protected $hidden = [
|
|
|
67 |
'password',
|
|
|
68 |
'remember_token',
|
|
|
69 |
];
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* The attributes that should be cast.
|
|
|
73 |
*
|
|
|
74 |
* @var array<string, string>
|
|
|
75 |
*/
|
|
|
76 |
protected $casts = [
|
|
|
77 |
'email_verified_at' => 'datetime',
|
|
|
78 |
];
|
|
|
79 |
|
|
|
80 |
/**
|
|
|
81 |
* Interact with the user's first name.
|
|
|
82 |
*
|
|
|
83 |
* @param string $value
|
|
|
84 |
* @return \Illuminate\Database\Eloquent\Casts\Attribute
|
|
|
85 |
*/
|
|
|
86 |
protected function google2faSecret(): Attribute
|
|
|
87 |
{
|
|
|
88 |
return new Attribute(
|
|
|
89 |
get: fn( $value ) => decrypt( $value ),
|
|
|
90 |
set: fn( $value ) => encrypt( $value ),
|
|
|
91 |
);
|
|
|
92 |
}
|
|
|
93 |
}
|