mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
58 lines
1.3 KiB
PHP
58 lines
1.3 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)
|
|
{
|
|
$value = is_array($value) ? $value : [$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);
|
|
}
|
|
}
|