<?php

use WoWPress\Models\Raid;
use WoWPress\Models\Signup;
use WoWPress\Models\User;

#dd($instance['count']);

$user = User::find(get_current_user_id());
$raids = Raid::where('start', '>', date('Y-m-d H:i', strtotime('NOW')))->get()->take(intval($instance['count']) ?: 1);
$character = $user->raiders->first();
if(!empty($character)){
?>

<div class="bg-glass shadow p-auto flex flex-col gap-auto order-last">
    <h1 class="text-xl font-bold text-center"><?= $this->title ?></h1>
    <?php if(!empty($character->ID)): ?>
    <?php foreach ($raids as $raid) : ?>
        <?php 
            ?>
        <div class="border shadow p-auto flex flex-col gap-2" style="background-position:center;background-size: cover;background-image:url('<?=$raid->thumbnail?>')">
            <h2 class="text-xl font-bold text-center"><a href="<?=$raid->link?>"><?= $raid->title ?></a></h2>
            <div class="text-center text-<?= $raid->color ?>"><?= $raid->difficulty ?></div>

            <div class="flex gap-1 justify-center">
            <div class="text-center text-white"><?= format_date($raid->start, 'E, dd.MM.') ?></div>
            <div class="text-center text-white"><?= format_date($raid->start, 'HH:mm') ?> - <?= format_date($raid->end, 'HH:mm') ?></div>
            </div>
            <?php
            $raid->showSignup($character,false, true, true);
            ?>
        </div>
    <?php endforeach; endif;?>
</div>
<?php }