]> git.localhorst.tv Git - alttp.git/blob - app/Models/User.php
clickable user boxes
[alttp.git] / app / Models / User.php
1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Foundation\Auth\User as Authenticatable;
7 use Illuminate\Notifications\Notifiable;
8 use Laravel\Sanctum\HasApiTokens;
9
10
11 class User extends Authenticatable
12 {
13         use HasApiTokens, HasFactory, Notifiable;
14
15         public function isParticipant(Tournament $tournament) {
16                 foreach ($tournament->participants as $participant) {
17                         if ($participant->user->id == $this->id) {
18                                 return true;
19                         }
20                 }
21                 return false;
22         }
23
24         /**
25          * The attributes that are mass assignable.
26          *
27          * @var string[]
28          */
29         protected $fillable = [
30                 'id',
31                 'username',
32                 'discriminator',
33                 'email',
34                 'avatar',
35                 'verified',
36                 'locale',
37                 'mfa_enabled',
38                 'refresh_token',
39                 'role',
40         ];
41
42         /**
43          * The attributes that should be hidden for serialization.
44          *
45          * @var array
46          */
47         protected $hidden = [
48                 'email',
49                 'mfa_enabled',
50                 'refresh_token',
51                 'remember_token',
52         ];
53
54         /**
55          * The attributes that should be cast.
56          *
57          * @var array
58          */
59         protected $casts = [
60                 'id' => 'string',
61                 'username' => 'string',
62                 'discriminator' => 'string',
63                 'email' => 'string',
64                 'avatar' => 'string',
65                 'verified' => 'boolean',
66                 'locale' => 'string',
67                 'mfa_enabled' => 'boolean',
68                 'refresh_token' => 'encrypted',
69         ];
70 }