]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/User.php
add user-sync discord command
[alttp.git] / app / Models / User.php
index 164fb026bfecba420a784daf83b44697f37cd869..879624a2072f58186e66ad107a604fd23e9f0d9f 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Foundation\Auth\User as Authenticatable;
 use Illuminate\Notifications\Notifiable;
@@ -28,6 +29,16 @@ class User extends Authenticatable
                return $this->username;
        }
 
+       public function getRandomQuoteAttribute() {
+               return $this->results()
+                       ->where('comment', '!=', '')
+                       ->whereHas('round', function(Builder $query) {
+                               $query->where('locked', true);
+                       })
+                       ->inRandomOrder()
+                       ->first();
+       }
+
 
        public function isAdmin() {
                return $this->role === 'admin';
@@ -204,6 +215,7 @@ class User extends Authenticatable
                'discriminator' => 'string',
                'email' => 'string',
                'avatar' => 'string',
+               'avatar_cached' => 'boolean',
                'verified' => 'boolean',
                'locale' => 'string',
                'mfa_enabled' => 'boolean',