247 lines
13 KiB
PHP
247 lines
13 KiB
PHP
@extends('layouts.app')
|
|||
|
|
|
||
|
|
@section('title', $topic->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"><a href="{{ route('forum.threads.show', $thread) }}" class="text-decoration-none">{{ $thread->title }}</a></li>
|
||
|
|
<li class="breadcrumb-item active">{{ $topic->title }}</li>
|
||
|
|
</ol>
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||
|
|
<div>
|
||
|
|
<h1 class="h2 fw-bold gradient-text">{{ $topic->title }}</h1>
|
||
|
|
<div class="text-muted">
|
||
|
|
<span>Started by <a href="{{ route('profile.show', $topic->user) }}" class="text-decoration-none">{{ $topic->user->name }}</a></span>
|
||
|
|
<span class="mx-1">•</span>
|
||
|
|
<span>{{ $topic->created_at->format('M j, Y g:i A') }}</span>
|
||
|
|
@if($topic->is_pinned)
|
||
|
|
<span class="badge bg-warning text-dark ms-2">Pinned</span>
|
||
|
|
@endif
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
@auth
|
||
|
|
@if(!$thread->is_locked)
|
||
|
|
<a href="{{ route('forum.posts.create', ['topic_id' => $topic->id]) }}" class="btn btn-gradient">
|
||
|
|
<i class="fas fa-reply me-1"></i> Reply
|
||
|
|
</a>
|
||
|
|
@endif
|
||
|
|
@if(auth()->id() === $topic->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.topics.edit', $topic) }}" class="dropdown-item">
|
||
|
|
<i class="fas fa-edit me-1"></i> Edit Topic
|
||
|
|
</a>
|
||
|
|
</li>
|
||
|
|
@if(auth()->user()->hasRole('admin'))
|
||
|
|
<li>
|
||
|
|
<form action="{{ route('forum.topics.update', $topic) }}" method="POST" class="d-inline">
|
||
|
|
@csrf
|
||
|
|
@method('PUT')
|
||
|
|
<input type="hidden" name="is_pinned" value="{{ $topic->is_pinned ? 0 : 1 }}">
|
||
|
|
<input type="hidden" name="title" value="{{ $topic->title }}">
|
||
|
|
<input type="hidden" name="content" value="{{ $topic->content }}">
|
||
|
|
<button type="submit" class="dropdown-item">
|
||
|
|
<i class="fas fa-thumbtack me-1"></i> {{ $topic->is_pinned ? 'Unpin' : 'Pin' }}
|
||
|
|
</button>
|
||
|
|
</form>
|
||
|
|
</li>
|
||
|
|
@endif
|
||
|
|
<li><hr class="dropdown-divider"></li>
|
||
|
|
<li>
|
||
|
|
<form action="{{ route('forum.topics.destroy', $topic) }}" 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 topic? All posts will be deleted.')">
|
||
|
|
<i class="fas fa-trash me-1"></i> Delete Topic
|
||
|
|
</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 Reply
|
||
|
|
</a>
|
||
|
|
@endauth
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Original Topic Post -->
|
||
|
|
<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('profile.show', $topic->user) }}" class="text-white text-decoration-none">
|
||
|
|
{{ $topic->user->name }}
|
||
|
|
</a>
|
||
|
|
</h5>
|
||
|
|
<div class="text-muted small">
|
||
|
|
<span>{{ $topic->created_at->format('M j, Y g:i A') }}</span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="card-body">
|
||
|
|
<div class="topic-content">
|
||
|
|
{!! nl2br(e($topic->content)) !!}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="card-footer bg-dark border-top border-secondary">
|
||
|
|
<div class="d-flex justify-content-between align-items-center">
|
||
|
|
<div>
|
||
|
|
<!-- Placeholder for potential like/share buttons -->
|
||
|
|
</div>
|
||
|
|
@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>
|
||
|
|
</div>
|
||
|
|
@endif
|
||
|
|
@endauth
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Replies/Posts -->
|
||
|
|
@if($posts->isEmpty())
|
||
|
|
<div class="card bg-dark text-white mb-4">
|
||
|
|
<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 replies yet</h3>
|
||
|
|
<p class="text-muted">Be the first to reply to this topic!</p>
|
||
|
|
@auth
|
||
|
|
@if(!$thread->is_locked)
|
||
|
|
<a href="{{ route('forum.posts.create', ['topic_id' => $topic->id]) }}" class="btn btn-gradient mt-3">
|
||
|
|
<i class="fas fa-reply me-1"></i> Post Reply
|
||
|
|
</a>
|
||
|
|
@else
|
||
|
|
<div class="alert alert-danger mt-3">
|
||
|
|
<i class="fas fa-lock me-1"></i> This thread is locked. You cannot post replies.
|
||
|
|
</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 Reply
|
||
|
|
</a>
|
||
|
|
@endauth
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
@else
|
||
|
|
<h3 class="h5 mb-3">Replies ({{ $posts->count() }})</h3>
|
||
|
|
<div class="posts-list">
|
||
|
|
@foreach($posts as $post)
|
||
|
|
<div class="card bg-dark text-white mb-4" id="post-{{ $post->id }}">
|
||
|
|
<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('profile.show', $post->user) }}" class="text-white text-decoration-none">
|
||
|
|
{{ $post->user->name }}
|
||
|
|
</a>
|
||
|
|
</h5>
|
||
|
|
<div class="text-muted small">
|
||
|
|
<span>{{ $post->created_at->format('M j, Y g:i A') }}</span>
|
||
|
|
@if($post->edited_at)
|
||
|
|
<span class="mx-1">•</span>
|
||
|
|
<span>Edited {{ $post->edited_at->diffForHumans() }}</span>
|
||
|
|
@endif
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<a href="#post-{{ $post->id }}" class="text-muted text-decoration-none">
|
||
|
|
<i class="fas fa-link"></i>
|
||
|
|
</a>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="card-body">
|
||
|
|
<div class="post-content">
|
||
|
|
{!! nl2br(e($post->content)) !!}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="card-footer bg-dark border-top border-secondary">
|
||
|
|
<div class="d-flex justify-content-between align-items-center">
|
||
|
|
<div>
|
||
|
|
@if($post->is_solution)
|
||
|
|
<span class="badge bg-success">
|
||
|
|
<i class="fas fa-check me-1"></i> Solution
|
||
|
|
</span>
|
||
|
|
@endif
|
||
|
|
</div>
|
||
|
|
@auth
|
||
|
|
@if(auth()->id() === $post->user_id || auth()->user()->hasRole('admin'))
|
||
|
|
<div class="d-flex gap-2">
|
||
|
|
<a href="{{ route('forum.posts.edit', $post) }}" class="btn btn-outline-primary btn-sm">
|
||
|
|
<i class="fas fa-edit"></i> Edit
|
||
|
|
</a>
|
||
|
|
<form action="{{ route('forum.posts.destroy', $post) }}" 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 post?')">
|
||
|
|
<i class="fas fa-trash"></i> Delete
|
||
|
|
</button>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
@endif
|
||
|
|
@endauth
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
@endforeach
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="d-flex justify-content-center">
|
||
|
|
{{ $posts->links() }}
|
||
|
|
</div>
|
||
|
|
@endif
|
||
|
|
|
||
|
|
<!-- Reply Form -->
|
||
|
|
@auth
|
||
|
|
@if(!$thread->is_locked)
|
||
|
|
<div class="card bg-dark text-white mt-4">
|
||
|
|
<div class="card-header">
|
||
|
|
<h5 class="mb-0">Post a Reply</h5>
|
||
|
|
</div>
|
||
|
|
<div class="card-body">
|
||
|
|
<form action="{{ route('forum.posts.store') }}" method="POST">
|
||
|
|
@csrf
|
||
|
|
<input type="hidden" name="topic_id" value="{{ $topic->id }}">
|
||
|
|
<div class="mb-3">
|
||
|
|
<textarea name="content" class="form-control bg-dark text-white" rows="5" placeholder="Write your reply here..." required></textarea>
|
||
|
|
</div>
|
||
|
|
<button type="submit" class="btn btn-gradient">
|
||
|
|
<i class="fas fa-paper-plane me-1"></i> Post Reply
|
||
|
|
</button>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
@else
|
||
|
|
<div class="alert alert-danger mt-4">
|
||
|
|
<i class="fas fa-lock me-1"></i> This thread is locked. You cannot post replies.
|
||
|
|
</div>
|
||
|
|
@endif
|
||
|
|
@endauth
|
||
|
|
</div>
|
||
|
|
@endsection
|