diff --git a/app/Http/Controllers/ChampionController.php b/app/Http/Controllers/ChampionController.php index dc2da65..7f19653 100644 --- a/app/Http/Controllers/ChampionController.php +++ b/app/Http/Controllers/ChampionController.php @@ -13,7 +13,11 @@ class ChampionController extends Controller */ public function index() { - // + $champions = Champion::orderBy('name')->get(); + + return view('champions.index', [ + 'champions' => $champions, + ]); } /** diff --git a/app/Models/Champion.php b/app/Models/Champion.php index 9fcc98c..b4e7b7e 100644 --- a/app/Models/Champion.php +++ b/app/Models/Champion.php @@ -6,6 +6,7 @@ use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; class Champion extends Model { @@ -46,11 +47,19 @@ class Champion extends Model return $this->hasMany(ChampionSkin::class); } - public function getChampionImageAttribute(): string + public function lanes(): HasOne { - return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/splash-art'; + return $this->hasOne(ChampionRoles::class, 'champion_id', 'champion_id'); } + public function getChampionImageAttribute($centered = true): string + { + $url = 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/splash-art'; + + return $centered ? $url . '/centered' : $url; + } + + public function getChampionImageLoadingAttribute(): string { return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/portrait'; diff --git a/app/Models/ChampionRoles.php b/app/Models/ChampionRoles.php index cc63dab..f4a1423 100644 --- a/app/Models/ChampionRoles.php +++ b/app/Models/ChampionRoles.php @@ -4,6 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class ChampionRoles extends Model { @@ -19,9 +20,9 @@ class ChampionRoles extends Model 'roles' => 'array', ]; - public function champion() + public function champion(): BelongsTo { - return $this->belongsTo(Champion::class); + return $this->belongsTo(Champion::class, 'champion_id', 'champion_id'); } public function getRolesAttribute($value): array @@ -46,4 +47,17 @@ class ChampionRoles extends Model return $transformedRoles; } + + public function getRoleIcon($roleName) + { + $roleIcons = [ + 'Toplane' => 'gm-top.png', + 'Jungle' => 'gm-jungle.png', + 'Midlane' => 'gm-mid.png', + 'Botlane' => 'gm-bot.png', + 'Support' => 'gm-support.png', + ]; + + return asset('img/' . $roleIcons[$roleName]); + } } diff --git a/app/View/Components/Champions/List_all.php b/app/View/Components/Champions/List_all.php new file mode 100644 index 0000000..9abc284 --- /dev/null +++ b/app/View/Components/Champions/List_all.php @@ -0,0 +1,18 @@ +hasAttributesChanged($chromaExists, $chromaAttributes)) { Log::info('Updating chroma: ' . $chromaId); $chromaExists->update($chromaAttributes); - } elseif (! $chromaExists) { + } elseif (!$chromaExists) { Log::info('Creating chroma: ' . $chromaId); SkinChroma::create($chromaAttributes); } @@ -55,7 +59,7 @@ class SkinChromaSeeder extends Seeder } } - private function hasAttributesChanged($chroma, $attributes) + private function hasAttributesChanged($chroma, $attributes): bool { foreach ($attributes as $key => $value) { if ($chroma->{$key} != $value) { diff --git a/public/img/gm-bot.png b/public/img/gm-bot.png new file mode 100644 index 0000000..e5fab7a Binary files /dev/null and b/public/img/gm-bot.png differ diff --git a/public/img/gm-jungle.png b/public/img/gm-jungle.png new file mode 100644 index 0000000..d2d7a14 Binary files /dev/null and b/public/img/gm-jungle.png differ diff --git a/public/img/gm-mid.png b/public/img/gm-mid.png new file mode 100644 index 0000000..b0726fb Binary files /dev/null and b/public/img/gm-mid.png differ diff --git a/public/img/gm-support.png b/public/img/gm-support.png new file mode 100644 index 0000000..f4087bf Binary files /dev/null and b/public/img/gm-support.png differ diff --git a/public/img/gm-top.png b/public/img/gm-top.png new file mode 100644 index 0000000..f5e7bfe Binary files /dev/null and b/public/img/gm-top.png differ diff --git a/resources/views/champions/index.blade.php b/resources/views/champions/index.blade.php new file mode 100644 index 0000000..fc6e1cd --- /dev/null +++ b/resources/views/champions/index.blade.php @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + Heimerdinger.LoL • Champions + + + + + + + + + + + + + + + + + + + + + + + + + @vite('resources/css/app.css') + @vite('resources/js/app.js') + + + + + + + + + diff --git a/resources/views/components/champions/list_all.blade.php b/resources/views/components/champions/list_all.blade.php new file mode 100644 index 0000000..e0cbc9f --- /dev/null +++ b/resources/views/components/champions/list_all.blade.php @@ -0,0 +1,65 @@ + + + +
+

+ Champions

+ +
+
+ @foreach($champions as $champion) +
+
+ {{ $champion->name }} Splash Art +
+
+
+

+ {{ $champion->name }} +

+ {{ $champion->title }} +
+ +
+

+ @foreach($champion->lanes->roles as $lane) + {{$lane}} + + {{$lane}} Icon +

+ @endforeach + + + +

+ + + +

+
+
+
+ @endforeach +
+
+
diff --git a/routes/web.php b/routes/web.php index c7f8b87..70560a2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@