feat: Add streamers to champion show view

- Added loading of streamers data in the champion show view.
- Updated ChampionController to load streamers for display.
This commit is contained in:
Rico van Zelst
2024-03-23 02:48:08 +01:00
parent b46128ec26
commit e6dcfacb31
10 changed files with 127 additions and 126 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Models\Champion;
class Streamer extends Model
{
@@ -11,10 +13,6 @@ class Streamer extends Model
protected $fillable = ['champion_id', 'platform', 'username', 'displayname'];
public function champion()
{
return $this->belongsTo(Champion::class);
}
public function getPlatformAttribute($value): string
{
@@ -39,4 +37,9 @@ class Streamer extends Model
'Huya' => "https://www.huya.com/{$this->username}",
};
}
public function champion(): BelongsTo
{
return $this->belongsTo(Champion::class, 'champion_id', 'champion_id');
}
}