diff --git a/app/Models/Champion.php b/app/Models/Champion.php index a7907ac..1eac51f 100644 --- a/app/Models/Champion.php +++ b/app/Models/Champion.php @@ -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'; } } diff --git a/app/Models/ChampionSkin.php b/app/Models/ChampionSkin.php index 4940cf4..5fb28c2 100644 --- a/app/Models/ChampionSkin.php +++ b/app/Models/ChampionSkin.php @@ -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); diff --git a/app/Models/SkinChroma.php b/app/Models/SkinChroma.php index 951fbec..3d070a7 100644 --- a/app/Models/SkinChroma.php +++ b/app/Models/SkinChroma.php @@ -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);