]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/DiscordGuild.php
track twitch category where chats were sent in
[alttp.git] / app / Models / DiscordGuild.php
index 361d6a911b54875ec8afdcf0d9b88c9495aaa0c0..bcbd12dd32b835a4b71bcabf774a0e6a1e31f424 100644 (file)
@@ -35,10 +35,21 @@ class DiscordGuild extends Model
                        $role_ids[] = $role->id;
                }
                $model->roles()->whereNotIn('role_id', $role_ids)->delete();
+
+               $channel_ids = [];
+               foreach ($guild->channels as $channel) {
+                       DiscordChannel::sync($model, $channel);
+                       $channel_ids[] = $channel->id;
+               }
+               $model->channels()->whereNotIn('channel_id', $channel_ids)->delete();
+       }
+
+       public function channels() {
+               return $this->hasMany(DiscordChannel::class)->orderBy('position');
        }
 
        public function roles() {
-               return $this->hasMany(DiscordRole::class);
+               return $this->hasMany(DiscordRole::class)->orderBy('position');
        }
 
        protected $fillable = [