mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
While the database values match the ones internally used by Riot Games in the League of Legends client, this is not how most people call them. So we map them to the way people call them for SEO
56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ChampionRoles extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'champion_id',
|
|
'champion_name',
|
|
'roles',
|
|
];
|
|
|
|
protected $casts = [
|
|
'roles' => 'array',
|
|
];
|
|
|
|
public function getRolesAttribute($value)
|
|
{
|
|
$mappedRoles = [];
|
|
foreach ($value as $role) {
|
|
switch ($role) {
|
|
case 'TOP':
|
|
$mappedRoles[] = 'Toplane';
|
|
break;
|
|
case 'JUNGLE':
|
|
$mappedRoles[] = 'Jungle';
|
|
break;
|
|
case 'MIDDLE':
|
|
$mappedRoles[] = 'Midlane';
|
|
break;
|
|
case 'BOTTOM':
|
|
$mappedRoles[] = 'Botlane';
|
|
break;
|
|
case 'UTILITY':
|
|
$mappedRoles[] = 'Support';
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return $mappedRoles;
|
|
}
|
|
|
|
|
|
public function champion()
|
|
{
|
|
return $this->belongsTo(Champion::class);
|
|
}
|
|
}
|