]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/User.php
show tournament participation in profile
[alttp.git] / app / Models / User.php
index 89963686eb21407d17eea9a5871d88658ff32d2b..535af2e07e828232ba2e9e2843ad507d1222d481 100644 (file)
@@ -2,43 +2,73 @@
 
 namespace App\Models;
 
-use Illuminate\Contracts\Auth\MustVerifyEmail;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Foundation\Auth\User as Authenticatable;
 use Illuminate\Notifications\Notifiable;
 use Laravel\Sanctum\HasApiTokens;
 
+
 class User extends Authenticatable
 {
-    use HasApiTokens, HasFactory, Notifiable;
-
-    /**
-     * The attributes that are mass assignable.
-     *
-     * @var array<int, string>
-     */
-    protected $fillable = [
-        'name',
-        'email',
-        'password',
-    ];
-
-    /**
-     * The attributes that should be hidden for serialization.
-     *
-     * @var array<int, string>
-     */
-    protected $hidden = [
-        'password',
-        'remember_token',
-    ];
-
-    /**
-     * The attributes that should be cast.
-     *
-     * @var array<string, string>
-     */
-    protected $casts = [
-        'email_verified_at' => 'datetime',
-    ];
+       use HasApiTokens, HasFactory, Notifiable;
+
+       public function isParticipant(Tournament $tournament) {
+               foreach ($tournament->participants as $participant) {
+                       if ($participant->user->id == $this->id) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       public function participation() {
+               return $this->hasMany(Participant::class);
+       }
+
+       /**
+        * The attributes that are mass assignable.
+        *
+        * @var string[]
+        */
+       protected $fillable = [
+               'id',
+               'username',
+               'discriminator',
+               'email',
+               'avatar',
+               'verified',
+               'locale',
+               'mfa_enabled',
+               'refresh_token',
+               'role',
+       ];
+
+       /**
+        * The attributes that should be hidden for serialization.
+        *
+        * @var array
+        */
+       protected $hidden = [
+               'email',
+               'mfa_enabled',
+               'refresh_token',
+               'remember_token',
+       ];
+
+       /**
+        * The attributes that should be cast.
+        *
+        * @var array
+        */
+       protected $casts = [
+               'id' => 'string',
+               'username' => 'string',
+               'discriminator' => 'string',
+               'email' => 'string',
+               'avatar' => 'string',
+               'verified' => 'boolean',
+               'locale' => 'string',
+               'mfa_enabled' => 'boolean',
+               'refresh_token' => 'encrypted',
+       ];
 }