]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/User.php
discord result command
[alttp.git] / app / Models / User.php
index ff45c6177c234acddda70e6b62493863fb48d151..164fb026bfecba420a784daf83b44697f37cd869 100644 (file)
@@ -12,6 +12,23 @@ class User extends Authenticatable
 {
        use HasApiTokens, HasFactory, Notifiable;
 
+       public function findResult(Round $round) {
+               foreach ($round->results as $result) {
+                       if ($this->id == $result->user_id) {
+                               return $result;
+                       }
+               }
+               return null;
+       }
+
+       public function getName() {
+               if (!empty($this->nickname)) {
+                       return $this->nickname;
+               }
+               return $this->username;
+       }
+
+
        public function isAdmin() {
                return $this->role === 'admin';
        }