-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUser.php
More file actions
124 lines (109 loc) · 4.55 KB
/
User.php
File metadata and controls
124 lines (109 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
namespace App;
use App\Notifications\ResetPasswordNotification;
use http\Exception\RuntimeException;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
/**
* App\User.
*
* @property int $id
* @property string $email
* @property string $password
* @property string|null $remember_token
* @property int $verified
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $stripe_id
* @property string|null $card_brand
* @property string|null $card_last_four
* @property string|null $trial_ends_at
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Client[] $clients
* @property-read int|null $clients_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Wiki[] $managesWikis
* @property-read int|null $manages_wikis_count
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
* @property-read int|null $notifications_count
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Token[] $tokens
* @property-read int|null $tokens_count
*
* @method static \Database\Factories\UserFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\User newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\User query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereCardBrand($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereCardLastFour($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePassword($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereRememberToken($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereStripeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereTrialEndsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereVerified($value)
*
* @mixin \Eloquent
*/
class User extends Authenticatable implements MustVerifyEmail {
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'email', 'password', 'verified', 'is_admin',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
'stripe_id',
'trial_ends_at',
'card_brand',
'card_last_four',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
public function sendPasswordResetNotification($token) {
$this->notify(new ResetPasswordNotification($token));
}
public function managesWikis(): \Illuminate\Database\Eloquent\Relations\BelongsToMany {
return $this->belongsToMany(Wiki::class, 'wiki_managers');
}
public function touAcceptances(): \Illuminate\Database\Eloquent\Relations\HasMany {
return $this->hasMany(UserTermsOfUseAcceptance::class, 'user_id');
}
public function hasVerifiedEmail() {
return (bool) $this->verified;
}
public function markEmailAsVerified() {
$this->verified = 1;
return true;
}
public function sendEmailVerificationNotification() {
// This is required by the MustVerifyEmail interface that we use for middle ware.
// But we currently send our emails via a different means, so we havn't implemented this..
// We can not throw an exception here as this is still called! (even if we don't use it)
// https://github.com/addshore/wbstack/issues/120
// throw new RuntimeException('Not yet implemented');
}
public function getEmailForVerification() {
return $this->email;
}
}