diff --git a/app/Http/Controllers/StreamerController.php b/app/Http/Controllers/StreamerController.php new file mode 100644 index 0000000..789e9d2 --- /dev/null +++ b/app/Http/Controllers/StreamerController.php @@ -0,0 +1,25 @@ +belongsTo(Champion::class); + } + + public function getPlatformAttribute($value): string + { + $platforms = [ + 'twitch' => 'Twitch', + 'youtube' => 'YouTube', + 'kick' => 'Kick', + 'douyu' => 'Douyu', + 'huya' => 'Huya', + ]; + + return $platforms[$value]; + } + + public function getStreamerUrlAttribute(): string + { + return match ($this->platform) { + 'Twitch' => "https://www.twitch.tv/{$this->username}", + 'YouTube' => "https://www.youtube.com/@{$this->username}", + 'Kick' => "https://kick.com/{$this->username}", + 'Douyu' => "https://www.douyu.com/{$this->username}", + 'Huya' => "https://www.huya.com/{$this->username}", + }; + } +} diff --git a/database/migrations/2024_03_20_233357_create_streamers_table.php b/database/migrations/2024_03_20_233357_create_streamers_table.php new file mode 100644 index 0000000..a69f5d8 --- /dev/null +++ b/database/migrations/2024_03_20_233357_create_streamers_table.php @@ -0,0 +1,31 @@ +id(); + $table->foreignId('champion_id')->constrained(); + $table->enum('platform', ['twitch', 'youtube', 'kick', 'douyu', 'huya']); + $table->string('username'); + $table->string('displayname'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('streamers'); + } +};