@php
use App\Models\Game;
use App\Models\GameList;
use App\Models\Platform;
use Illuminate\Support\Str;
@endphp

<x-base-layout>

    <!--begin::Row-->
    <div class="row gy-5 g-xl-8">
        <!--begin::Col-->
        <div class="col-xxl-8">
            <div class="card shadow-sm mb-2">
                <div class="card-header">
                    <h3 class="card-title">Wishlist</h3>
                </div>
                <div class="card-body">
                    @if (count($wishlist) === 0)
                        <p class="text-gray-800 fw-normal mt-3 mb-5">There are no games on this wishlist.</p>
                    @else
                    @foreach ($wishlist as $item)
                        @php
                            $game = Game::find($item->game_id);

                            if ($game === null) {
                                continue;
                            }

                            $gameName = str_replace('/', '_', str_replace(' ', '_', $game->name));
                            $platform = Platform::whereId($game->platform_id)->get();
                        @endphp
                    <!--begin::Game-->
                    <div class="d-flex align-items-start flex-grow-1">
                        <!--begin::Boxart-->
                        <div class="me-5">
                            <img class="mw-125px img-thumbnail" src="{{ Storage::url('assets/boxart/') . $game->boxart }}" alt="">
                        </div>
                        <!--end::Boxart-->
                        <!--begin::Info-->
                        <div class="d-flex flex-column">
                            <div class="d-flex justify-content-between">
                                <a href="/game/{{ $game->id }}/{{ $gameName }}" class="text-primary-900 text-hover-primary-600 fs-3 fw-bolder">{{ $game->name }}</a>

                            </div>
                            @if ($game->alt_titles)
                                @php
                                    $altTitles = str_replace('|', ', ', $game->alt_titles);
                                @endphp
                            <span class="text-dark"><span class="fw-bolder">Alternative Titles:</span> {{ $altTitles }}</span>
                            @endif
                            <p class="text-gray-800 fw-normal mt-3 mb-5">{{ Str::words($game->description, 50) }}</p>
                        </div>
                        <!--end::Info-->
                    </div>
                    <!--end::Game-->
                    <div class="separator my-5"></div>
                    @endforeach
                    @endif
                </div>
            </div>
        </div>
        <!--end::Col-->
    </div>
    <!--end::Row-->

</x-base-layout>


