mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: upcoming skins & feat: return types
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Champion extends Model
|
||||
{
|
||||
@@ -40,52 +41,52 @@ class Champion extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public function skins()
|
||||
public function skins(): HasMany
|
||||
{
|
||||
return $this->hasMany(ChampionSkin::class);
|
||||
}
|
||||
|
||||
public function getChampionImageAttribute()
|
||||
public function getChampionImageAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/splash-art';
|
||||
}
|
||||
|
||||
public function getChampionImageLoadingAttribute()
|
||||
public function getChampionImageLoadingAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/portrait';
|
||||
}
|
||||
|
||||
public function getChampionImageTileAttribute()
|
||||
public function getChampionImageTileAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/tile';
|
||||
}
|
||||
|
||||
public function getChampionSquareImageAttribute()
|
||||
public function getChampionSquareImageAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/square';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconQAttribute()
|
||||
public function getChampionAbilityIconQAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/q';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconWAttribute()
|
||||
public function getChampionAbilityIconWAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/w';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconEAttribute()
|
||||
public function getChampionAbilityIconEAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/e';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconRAttribute()
|
||||
public function getChampionAbilityIconRAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/r';
|
||||
}
|
||||
|
||||
public function getChampionAbilityIconPAttribute()
|
||||
public function getChampionAbilityIconPAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/ability-icon/p';
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class ChampionRoles extends Model
|
||||
return $this->belongsTo(Champion::class);
|
||||
}
|
||||
|
||||
public function getRolesAttribute($value)
|
||||
public function getRolesAttribute($value): array
|
||||
{
|
||||
$value = json_decode($value);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace App\Models;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ChampionSkin extends Model
|
||||
{
|
||||
@@ -47,28 +49,33 @@ class ChampionSkin extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public function champion()
|
||||
public function champion(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Champion::class);
|
||||
}
|
||||
|
||||
public function chromas()
|
||||
public function chromas(): HasMany
|
||||
{
|
||||
return $this->hasMany(SkinChroma::class, 'full_skin_id', 'full_skin_id');
|
||||
}
|
||||
|
||||
public function getSkinImageAttribute()
|
||||
public function getSkinImageAttribute(bool $pbe = false): string
|
||||
{
|
||||
if ($pbe) {
|
||||
return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-splashes/' . $this->champion_id . '/' . $this->full_skin_id . '.jpg';
|
||||
}
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/splash-art/centered/skin/' . $this->skin_id;
|
||||
}
|
||||
|
||||
public function getSkinImageLoadingAttribute()
|
||||
public function getSkinImageLoadingAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/portrait/skin/' . $this->skin_id;
|
||||
}
|
||||
|
||||
public function getSkinImageTileAttribute()
|
||||
public function getSkinImageTileAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/tile/skin/' . $this->skin_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class SkinChroma extends Model
|
||||
{
|
||||
@@ -25,7 +26,6 @@ class SkinChroma extends Model
|
||||
|
||||
public function sluggable(): array
|
||||
{
|
||||
// chroma name + skin name
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => ['chroma_name', 'skin_name'],
|
||||
@@ -33,7 +33,7 @@ class SkinChroma extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public function skin()
|
||||
public function skin(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Skin::class);
|
||||
}
|
||||
|
||||
18
app/View/Components/home/Upcoming_skins.php
Normal file
18
app/View/Components/home/Upcoming_skins.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Home;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Upcoming_skins extends Component
|
||||
{
|
||||
public function __construct(public array $skins)
|
||||
{
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('components.home.upcoming_skins');
|
||||
}
|
||||
}
|
||||
53
resources/views/components/home/upcoming_skins.blade.php
Normal file
53
resources/views/components/home/upcoming_skins.blade.php
Normal file
@@ -0,0 +1,53 @@
|
||||
@php use Carbon\Carbon; @endphp
|
||||
<?php
|
||||
/** @var App\Models\ChampionSkin $skin */ ?>
|
||||
|
||||
<section class="text-white bg-stone-900">
|
||||
<div class="max-w-screen-xl px-4 py-8 mx-auto sm:py-12 sm:px-6 lg:py-16 lg:px-8">
|
||||
<div class="max-w-lg mx-auto text-center">
|
||||
<h2
|
||||
class="text-3xl font-bold text-transparent uppercase sm:text-4xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
|
||||
Upcoming Skins</h2>
|
||||
|
||||
<p class="mt-4 text-stone-300">
|
||||
Check out upcoming skins in League of Legends. <br>
|
||||
<span class="text-sm text-stone-400">Data is updated roughly every 12 hours.</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-4 mt-8 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-3">
|
||||
@foreach ($skins as $skin)
|
||||
@if($skin->availability == "Upcoming")
|
||||
<div
|
||||
class="p-8 transition border shadow-xl border-stone-800 rounded-xl hover:border-orange-500/10 hover:shadow-orange-500/10">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex flex-col items-center justify-center">
|
||||
<img loading="lazy" class="border-2 border-orange-400/40 rounded-xl"
|
||||
src="{{ $skin->getSkinImageAttribute(true) }}"
|
||||
alt="{{ $skin->skin_name }} Splash Art">
|
||||
<div class="flex flex-col items-center justify-center">
|
||||
<h2 class="mt-4 text-xl font-bold text-white">{{ $skin->skin_name }}</h2>
|
||||
<p class="mt-1 text-sm text-stone-300">
|
||||
@if ($skin->rp_price == '99999')
|
||||
Not Available for RP
|
||||
@else
|
||||
{{ $skin->rp_price }} RP
|
||||
@endif
|
||||
|
||||
</p>
|
||||
<p class="mt-1 text-sm italic text-stone-300">
|
||||
@if ($skin->loot_eligible)
|
||||
Can be obtained from loot
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
@@ -28,9 +28,10 @@
|
||||
</head>
|
||||
|
||||
<body class="antialiased bg-stone-800 dark">
|
||||
<x-navbar />
|
||||
<x-home.features />
|
||||
<x-home.recent_skins :skins="$skins" />
|
||||
<x-navbar/>
|
||||
<x-home.features/>
|
||||
<x-home.upcoming_skins :skins="$skins"/>
|
||||
<x-home.recent_skins :skins="$skins"/>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user