Files
2026-02-22 20:02:34 +02:00

196 lines
11 KiB
PHP

@extends('layouts.app')
@section('title', $thread->title . ' - Forum - ClearGame')
@section('content')
<div class="container">
<nav aria-label="breadcrumb" class="mb-4">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('forum.index') }}" class="text-decoration-none">Forum</a></li>
<li class="breadcrumb-item"><a href="{{ route('forum.categories.show', $thread->category) }}" class="text-decoration-none">{{ $thread->category->name }}</a></li>
<li class="breadcrumb-item active">{{ $thread->title }}</li>
</ol>
</nav>
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="h2 fw-bold gradient-text">{{ $thread->title }}</h1>
<div class="text-muted">
<span>Started by <a href="{{ route('profile.show', $thread->user) }}" class="text-decoration-none">{{ $thread->user->name }}</a></span>
<span class="mx-1">•</span>
<span>{{ $thread->created_at->format('M j, Y g:i A') }}</span>
<span class="mx-1">•</span>
<span>{{ $thread->views }} views</span>
@if($thread->is_sticky)
<span class="badge bg-warning text-dark ms-2">Sticky</span>
@endif
@if($thread->is_locked)
<span class="badge bg-danger ms-2">Locked</span>
@endif
</div>
</div>
<div>
@auth
@if(!$thread->is_locked)
<a href="{{ route('forum.topics.create', ['thread_id' => $thread->id]) }}" class="btn btn-gradient">
<i class="fas fa-plus me-1"></i> New Topic
</a>
@endif
@if(auth()->id() === $thread->user_id || auth()->user()->hasRole('admin'))
<div class="dropdown d-inline-block ms-2">
<button class="btn btn-outline-light dropdown-toggle" type="button" data-bs-toggle="dropdown">
<i class="fas fa-cog"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li>
<a href="{{ route('forum.threads.edit', $thread) }}" class="dropdown-item">
<i class="fas fa-edit me-1"></i> Edit Thread
</a>
</li>
@if(auth()->user()->hasRole('admin'))
<li>
<form action="{{ route('forum.threads.update', $thread) }}" method="POST" class="d-inline">
@csrf
@method('PUT')
<input type="hidden" name="is_sticky" value="{{ $thread->is_sticky ? 0 : 1 }}">
<input type="hidden" name="title" value="{{ $thread->title }}">
<input type="hidden" name="category_id" value="{{ $thread->category_id }}">
<button type="submit" class="dropdown-item">
<i class="fas fa-thumbtack me-1"></i> {{ $thread->is_sticky ? 'Unsticky' : 'Sticky' }}
</button>
</form>
</li>
<li>
<form action="{{ route('forum.threads.update', $thread) }}" method="POST" class="d-inline">
@csrf
@method('PUT')
<input type="hidden" name="is_locked" value="{{ $thread->is_locked ? 0 : 1 }}">
<input type="hidden" name="title" value="{{ $thread->title }}">
<input type="hidden" name="category_id" value="{{ $thread->category_id }}">
<button type="submit" class="dropdown-item">
<i class="fas fa-lock me-1"></i> {{ $thread->is_locked ? 'Unlock' : 'Lock' }}
</button>
</form>
</li>
@endif
<li><hr class="dropdown-divider"></li>
<li>
<form action="{{ route('forum.threads.destroy', $thread) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="dropdown-item text-danger" onclick="return confirm('Are you sure you want to delete this thread? All topics and posts will be deleted.')">
<i class="fas fa-trash me-1"></i> Delete Thread
</button>
</form>
</li>
</ul>
</div>
@endif
@else
<a href="{{ route('login') }}" class="btn btn-gradient">
<i class="fas fa-sign-in-alt me-1"></i> Login to Post
</a>
@endauth
</div>
</div>
@if($topics->isEmpty())
<div class="card bg-dark text-white">
<div class="card-body text-center py-5">
<i class="fas fa-comments fa-3x text-muted mb-3"></i>
<h3 class="text-muted">No topics yet</h3>
<p class="text-muted">Be the first to start a topic in this thread!</p>
@auth
@if(!$thread->is_locked)
<a href="{{ route('forum.topics.create', ['thread_id' => $thread->id]) }}" class="btn btn-gradient mt-3">
<i class="fas fa-plus me-1"></i> Create Topic
</a>
@else
<div class="alert alert-danger mt-3">
<i class="fas fa-lock me-1"></i> This thread is locked. You cannot create new topics.
</div>
@endif
@else
<a href="{{ route('login') }}" class="btn btn-gradient mt-3">
<i class="fas fa-sign-in-alt me-1"></i> Login to Create Topic
</a>
@endauth
</div>
</div>
@else
<div class="topics-list">
@foreach($topics as $topic)
<div class="card bg-dark text-white mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center">
<div class="me-3">
<i class="fas fa-user-circle fa-2x"></i>
</div>
<div>
<h5 class="mb-0">
<a href="{{ route('forum.topics.show', $topic) }}" class="text-white text-decoration-none">
{{ $topic->title }}
</a>
@if($topic->is_pinned)
<span class="badge bg-warning text-dark ms-2">Pinned</span>
@endif
</h5>
<div class="text-muted small">
Posted by <a href="{{ route('profile.show', $topic->user) }}" class="text-decoration-none">{{ $topic->user->name }}</a>
<span class="mx-1">•</span>
<span>{{ $topic->created_at->diffForHumans() }}</span>
</div>
</div>
</div>
<div class="text-muted small">
<span>{{ $topic->posts->count() }} {{ Str::plural('reply', $topic->posts->count()) }}</span>
</div>
</div>
<div class="card-body">
<div class="topic-content">
{!! nl2br(e(Str::limit($topic->content, 300))) !!}
@if(strlen($topic->content) > 300)
<a href="{{ route('forum.topics.show', $topic) }}" class="text-primary">Read more</a>
@endif
</div>
</div>
<div class="card-footer bg-dark border-top border-secondary">
<div class="d-flex justify-content-between align-items-center">
<a href="{{ route('forum.topics.show', $topic) }}" class="btn btn-link text-white p-0">
View full topic
</a>
@auth
@if(auth()->id() === $topic->user_id || auth()->user()->hasRole('admin'))
<div class="d-flex gap-2">
<a href="{{ route('forum.topics.edit', $topic) }}" class="btn btn-outline-primary btn-sm">
<i class="fas fa-edit"></i> Edit
</a>
<form action="{{ route('forum.topics.destroy', $topic) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-outline-danger btn-sm" onclick="return confirm('Are you sure you want to delete this topic?')">
<i class="fas fa-trash"></i> Delete
</button>
</form>
</div>
@endif
@endauth
</div>
</div>
</div>
@endforeach
</div>
<div class="d-flex justify-content-center">
{{ $topics->links() }}
</div>
@endif
@if($thread->is_locked)
<div class="alert alert-danger mt-4">
<i class="fas fa-lock me-1"></i> This thread is locked. You cannot create new topics.
</div>
@endif
</div>
@endsection