@php /** @var LaraBB\Forum\Models\Forum $forum */ @endphp
@extends('admin::Layouts.master')
@section('content')
<div class="container-fluid py-4">
    @include('partials.messages')
    @include('partials.button', ['context' => 'primary', 'href' => 'admin.forums.category.create', 'parameters' => [], 'icon' => 'plus', 'label' => 'Neue Kategorie erstellen'])
    @include('partials.button', ['context' => 'primary', 'href' => 'admin.forums.create', 'parameters' => [], 'icon' => 'plus', 'label' => 'Neues Forum erstellen'])
    <div class="d-none d-lg-flex mt-4 py-2">
        <div class="col-12 col-lg-9 font-weight-bold">Forum</div>
        <div class="col-12 col-lg-1 font-weight-bold text-center">Themen</div>
        <div class="col-12 col-lg-1 font-weight-bold text-center">Beiträge</div>
    </div>
    @forelse($categories as $category)
    <div class="d-flex hover align-items-center{{ $loop->last && $category->forums->isEmpty() ? ' mb-3' : '' }}">
        <div class="col-12 col-lg-11 font-weight-bold">
            <a href="{{ route('admin.forums.category.edit', [$category->uuid]) }}">{{ $category->title }}</a>
        </div>
        <div class="col-12 col-lg-1 text-right">
            <form action="{{ route('admin.forums.category.destroy') }}" method="post" class="delete" data-message="Wollen Sie diese Kategorie wirklich löschen?">
                @csrf
                <input type="hidden" name="uuid" value="{{ $category->uuid }}">
                <button class="btn">
                    <span class="far fa-fw fa-trash-alt"></span>
                </button>
            </form>
        </div>
    </div>
    @forelse($category->forums as $forum)
    <div class="d-flex hover align-items-center{{ $loop->last ? ' mb-3' : '' }}">
        <div class="col-12 col-lg-9">
            <a href="{{ route('admin.forums.edit', [$forum->uuid]) }}">
                <span class="fw-lighter">⤷</span> {{ $forum->title }}
            </a>
        </div>
        <div class="col-12 col-lg-1 text-center">
            {{ $forum->thread_count }}
        </div>
        <div class="col-12 col-lg-1 text-center">
            {{ $forum->posting_count }}
        </div>
        <div class="col-12 col-lg-1 text-right">
            <form action="{{ route('admin.forums.destroy') }}" method="post" class="delete" data-message="Wollen Sie dieses Forum wirklich löschen?">
                @csrf
                <input type="hidden" name="uuid" value="{{ $forum->uuid }}">
                <button class="btn">
                    <span class="far fa-fw fa-trash-alt"></span>
                </button>
            </form>
        </div>
    </div>
    @if(!$loop->last) <hr class="my-0"> @endif
    @empty
    <div class="row mb-3">
        <div class="col-12 text-center">
            Es sind keine Foren in dieser Kategorie vorhanden.
        </div>
    </div>
    @endforelse
    @empty
    <div class="row mb-3">
        <div class="col-12 text-center">
            Es sind keine Kategorien in der Datenbank vorhanden.
        </div>
    </div>
    @endforelse
    @include('partials.button', ['context' => 'primary', 'href' => 'admin.forums.category.create', 'parameters' => [], 'icon' => 'plus', 'label' => 'Neue Kategorie erstellen'])
    @include('partials.button', ['context' => 'primary', 'href' => 'admin.forums.create', 'parameters' => [], 'icon' => 'plus', 'label' => 'Neues Forum erstellen'])
</div>
@stop
