mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: make models sluggable
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Champion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = [
|
||||
'champion_id',
|
||||
@@ -29,6 +31,15 @@ class Champion extends Model
|
||||
'roles' => 'array',
|
||||
];
|
||||
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function skins()
|
||||
{
|
||||
return $this->hasMany(ChampionSkin::class);
|
||||
@@ -36,46 +47,46 @@ class Champion extends Model
|
||||
|
||||
public function getChampionImageAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/splash-art';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/splash-art';
|
||||
}
|
||||
|
||||
public function getChampionImageLoadingAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/portrait';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/portrait';
|
||||
}
|
||||
|
||||
public function getChampionImageTileAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/tile';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/tile';
|
||||
}
|
||||
|
||||
public function getChampionSquareImageAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/square';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/square';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconQAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/ability-icon/q';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/q';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconWAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/ability-icon/w';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/w';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconEAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/ability-icon/e';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/e';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconRAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/ability-icon/r';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/r';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconPAttribute()
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/ability-icon/p';
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/p';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ChampionSkin extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = [
|
||||
'champion_id',
|
||||
@@ -36,6 +38,15 @@ class ChampionSkin extends Model
|
||||
'splash_artist' => 'array',
|
||||
];
|
||||
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'skin_name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function champion()
|
||||
{
|
||||
return $this->belongsTo(Champion::class);
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SkinChroma extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = [
|
||||
'full_skin_id',
|
||||
@@ -21,6 +23,16 @@ class SkinChroma extends Model
|
||||
'chroma_colors' => 'array',
|
||||
];
|
||||
|
||||
public function sluggable(): array
|
||||
{
|
||||
$slug = $this->chroma_name . ' ' . $this->skin_name;
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => $slug
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function skin()
|
||||
{
|
||||
return $this->belongsTo(Skin::class);
|
||||
|
||||
Reference in New Issue
Block a user