mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
- Added StreamerController with index and show methods - Added StreamerPanelController with index, create, store, edit, update, and destroy methods - Created Streamer model with fillable attributes and platform-specific URL generation logic - Implemented migration for creating the streamers table
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Streamer extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['champion_id', 'platform', 'username', 'displayname'];
|
|
|
|
public function champion()
|
|
{
|
|
return $this->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}",
|
|
};
|
|
}
|
|
}
|