lots of improvements

This commit is contained in:
Doar Mihai
2026-02-22 20:02:34 +02:00
parent 83fc389755
commit 29b5eca900
69 changed files with 3460 additions and 434 deletions
@@ -0,0 +1,51 @@
@extends('layouts.app')
@section('title', 'Create Category - 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 active">Create Category</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Create New Category</h1>
</div>
<div class="card-body">
<form action="{{ route('forum.categories.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="name" class="form-label">Category Name</label>
<input type="text" class="form-control bg-dark text-white @error('name') is-invalid @enderror" id="name" name="name" value="{{ old('name') }}" required>
@error('name')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control bg-dark text-white @error('description') is-invalid @enderror" id="description" name="description" rows="3">{{ old('description') }}</textarea>
@error('description')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="order" class="form-label">Display Order</label>
<input type="number" class="form-control bg-dark text-white @error('order') is-invalid @enderror" id="order" name="order" value="{{ old('order', 0) }}">
<div class="form-text text-muted">Categories with lower numbers will be displayed first.</div>
@error('order')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Create Category</button>
<a href="{{ route('forum.index') }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,53 @@
@extends('layouts.app')
@section('title', 'Edit Category - 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', $category) }}" class="text-decoration-none">{{ $category->name }}</a></li>
<li class="breadcrumb-item active">Edit</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Edit Category</h1>
</div>
<div class="card-body">
<form action="{{ route('forum.categories.update', $category) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="name" class="form-label">Category Name</label>
<input type="text" class="form-control bg-dark text-white @error('name') is-invalid @enderror" id="name" name="name" value="{{ old('name', $category->name) }}" required>
@error('name')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control bg-dark text-white @error('description') is-invalid @enderror" id="description" name="description" rows="3">{{ old('description', $category->description) }}</textarea>
@error('description')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="order" class="form-label">Display Order</label>
<input type="number" class="form-control bg-dark text-white @error('order') is-invalid @enderror" id="order" name="order" value="{{ old('order', $category->order) }}">
<div class="form-text text-muted">Categories with lower numbers will be displayed first.</div>
@error('order')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Update Category</button>
<a href="{{ route('forum.categories.show', $category) }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,150 @@
@extends('layouts.app')
@section('title', $category->name . ' - 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 active">{{ $category->name }}</li>
</ol>
</nav>
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="h2 fw-bold gradient-text">{{ $category->name }}</h1>
<p class="text-muted">{{ $category->description }}</p>
</div>
<div>
@auth
<a href="{{ route('forum.threads.create', ['category_id' => $category->id]) }}" class="btn btn-gradient">
<i class="fas fa-plus me-1"></i> New Thread
</a>
@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($threads->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 threads yet</h3>
<p class="text-muted">Be the first to start a discussion in this category!</p>
@auth
<a href="{{ route('forum.threads.create', ['category_id' => $category->id]) }}" class="btn btn-gradient mt-3">
<i class="fas fa-plus me-1"></i> Create Thread
</a>
@else
<a href="{{ route('login') }}" class="btn btn-gradient mt-3">
<i class="fas fa-sign-in-alt me-1"></i> Login to Create Thread
</a>
@endauth
</div>
</div>
@else
<div class="card bg-dark text-white mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">Threads</h5>
<div class="dropdown">
<button class="btn btn-sm btn-outline-light dropdown-toggle" type="button" data-bs-toggle="dropdown">
<i class="fas fa-sort me-1"></i> Sort
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="{{ route('forum.categories.show', ['category' => $category, 'sort' => 'latest']) }}">Latest Activity</a></li>
<li><a class="dropdown-item" href="{{ route('forum.categories.show', ['category' => $category, 'sort' => 'newest']) }}">Newest</a></li>
<li><a class="dropdown-item" href="{{ route('forum.categories.show', ['category' => $category, 'sort' => 'views']) }}">Most Viewed</a></li>
</ul>
</div>
</div>
<div class="list-group list-group-flush">
@foreach($threads as $thread)
<div class="list-group-item bg-dark text-white border-secondary {{ $thread->is_sticky ? 'bg-dark bg-opacity-75' : '' }}">
<div class="row align-items-center">
<div class="col-md-7">
<div class="d-flex align-items-center">
<div class="me-3">
@if($thread->is_sticky)
<i class="fas fa-thumbtack fa-lg text-warning"></i>
@elseif($thread->is_locked)
<i class="fas fa-lock fa-lg text-danger"></i>
@else
<i class="fas fa-comments fa-lg text-primary"></i>
@endif
</div>
<div>
<h5 class="mb-1">
<a href="{{ route('forum.threads.show', $thread) }}" class="text-white text-decoration-none">
{{ $thread->title }}
</a>
@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
</h5>
<div class="text-muted small">
Started by <a href="{{ route('profile.show', $thread->user) }}" class="text-decoration-none">{{ $thread->user->name }}</a>
<span class="mx-1">•</span>
<span>{{ $thread->created_at->diffForHumans() }}</span>
</div>
</div>
</div>
</div>
<div class="col-md-2 text-center">
<div class="text-muted">
<span class="d-block">{{ $thread->topics->count() }}</span>
<small>Topics</small>
</div>
</div>
<div class="col-md-1 text-center">
<div class="text-muted">
<span class="d-block">{{ $thread->views }}</span>
<small>Views</small>
</div>
</div>
<div class="col-md-2">
@if($thread->last_activity_at)
<div class="small text-end">
<div class="text-muted">
<small>
<i class="far fa-clock me-1"></i> {{ $thread->last_activity_at->diffForHumans() }}
</small>
</div>
</div>
@endif
</div>
</div>
</div>
@endforeach
</div>
</div>
<div class="d-flex justify-content-center">
{{ $threads->links() }}
</div>
@endif
@auth
@if(auth()->user()->hasRole('admin'))
<div class="mt-4 d-flex gap-2">
<a href="{{ route('forum.categories.edit', $category) }}" class="btn btn-outline-primary">
<i class="fas fa-edit me-1"></i> Edit Category
</a>
<form action="{{ route('forum.categories.destroy', $category) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-outline-danger" onclick="return confirm('Are you sure you want to delete this category? All threads and posts will be deleted.')">
<i class="fas fa-trash me-1"></i> Delete Category
</button>
</form>
</div>
@endif
@endauth
</div>
@endsection
+104
View File
@@ -0,0 +1,104 @@
@extends('layouts.app')
@section('title', 'Forum - ClearGame')
@section('content')
<div class="container">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h2 fw-bold gradient-text">Forum</h1>
@auth
@if(auth()->user()->hasRole('admin'))
<a href="{{ route('forum.categories.create') }}" class="btn btn-gradient">
<i class="fas fa-plus me-1"></i> New Category
</a>
@endif
@endauth
</div>
@if($categories->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 categories yet</h3>
<p class="text-muted">Check back later for forum discussions.</p>
</div>
</div>
@else
<div class="card bg-dark text-white mb-4">
<div class="card-header">
<h5 class="mb-0">Categories</h5>
</div>
<div class="list-group list-group-flush">
@foreach($categories as $category)
<div class="list-group-item bg-dark text-white border-secondary">
<div class="row align-items-center">
<div class="col-md-7">
<div class="d-flex align-items-center">
<div class="me-3">
<i class="fas fa-folder fa-2x text-primary"></i>
</div>
<div>
<h5 class="mb-1">
<a href="{{ route('forum.categories.show', $category) }}" class="text-white text-decoration-none">
{{ $category->name }}
</a>
</h5>
<p class="text-muted mb-0">{{ $category->description }}</p>
</div>
</div>
</div>
<div class="col-md-2 text-center">
<div class="text-muted">
<span class="d-block">{{ $category->threads->count() }}</span>
<small>Threads</small>
</div>
</div>
<div class="col-md-3">
@if($category->threads->count() > 0)
@php
$latestThread = $category->threads()->orderBy('last_activity_at', 'desc')->first();
@endphp
<div class="small">
<a href="{{ route('forum.threads.show', $latestThread) }}" class="text-white">
{{ Str::limit($latestThread->title, 30) }}
</a>
<div class="text-muted">
<small>
<i class="far fa-clock me-1"></i> {{ $latestThread->last_activity_at->diffForHumans() }}
</small>
</div>
</div>
@else
<div class="text-muted small">No threads yet</div>
@endif
</div>
</div>
</div>
@endforeach
</div>
</div>
@endif
<div class="card bg-dark text-white">
<div class="card-header">
<h5 class="mb-0">Forum Statistics</h5>
</div>
<div class="card-body">
<div class="row text-center">
<div class="col-md-4">
<h3 class="gradient-text">{{ \App\Models\ForumThread::count() }}</h3>
<p class="text-muted">Threads</p>
</div>
<div class="col-md-4">
<h3 class="gradient-text">{{ \App\Models\ForumTopic::count() }}</h3>
<p class="text-muted">Topics</p>
</div>
<div class="col-md-4">
<h3 class="gradient-text">{{ \App\Models\ForumPost::count() }}</h3>
<p class="text-muted">Posts</p>
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,71 @@
@extends('layouts.app')
@section('title', 'Reply to Topic - 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"><a href="{{ route('forum.topics.show', $topic) }}" class="text-decoration-none">{{ $topic->title }}</a></li>
<li class="breadcrumb-item active">Reply</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Reply to Topic</h1>
<p class="text-muted mb-0">{{ $topic->title }}</p>
</div>
<div class="card-body">
<!-- Original Topic Content (for reference) -->
<div class="card bg-dark border-secondary mb-4">
<div class="card-header">
<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(Str::limit($topic->content, 300))) !!}
@if(strlen($topic->content) > 300)
<a href="{{ route('forum.topics.show', $topic) }}" class="text-primary">Read full topic</a>
@endif
</div>
</div>
</div>
<!-- Reply Form -->
<form action="{{ route('forum.posts.store') }}" method="POST">
@csrf
<input type="hidden" name="topic_id" value="{{ $topic->id }}">
<div class="mb-3">
<label for="content" class="form-label">Your Reply</label>
<textarea class="form-control bg-dark text-white @error('content') is-invalid @enderror" id="content" name="content" rows="10" required>{{ old('content') }}</textarea>
@error('content')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Post Reply</button>
<a href="{{ route('forum.topics.show', $topic) }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,54 @@
@extends('layouts.app')
@section('title', 'Edit Reply - 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', $post->topic->thread->category) }}" class="text-decoration-none">{{ $post->topic->thread->category->name }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('forum.threads.show', $post->topic->thread) }}" class="text-decoration-none">{{ $post->topic->thread->title }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('forum.topics.show', $post->topic) }}" class="text-decoration-none">{{ $post->topic->title }}</a></li>
<li class="breadcrumb-item active">Edit Reply</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Edit Reply</h1>
<p class="text-muted mb-0">in topic: {{ $post->topic->title }}</p>
</div>
<div class="card-body">
<form action="{{ route('forum.posts.update', $post) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="content" class="form-label">Content</label>
<textarea class="form-control bg-dark text-white @error('content') is-invalid @enderror" id="content" name="content" rows="10" required>{{ old('content', $post->content) }}</textarea>
@error('content')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
@if(auth()->user()->hasRole('admin'))
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="is_solution" name="is_solution" value="1" {{ old('is_solution', $post->is_solution) ? 'checked' : '' }}>
<label class="form-check-label" for="is_solution">
Mark as Solution
</label>
<div class="form-text text-muted">Mark this post as the solution to the topic.</div>
</div>
</div>
@endif
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Update Reply</button>
<a href="{{ route('forum.topics.show', $post->topic) }}#post-{{ $post->id }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,70 @@
@extends('layouts.app')
@section('title', 'Create Thread - 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>
@if(isset($category_id))
@php
$category = \App\Models\ForumCategory::find($category_id);
@endphp
@if($category)
<li class="breadcrumb-item"><a href="{{ route('forum.categories.show', $category) }}" class="text-decoration-none">{{ $category->name }}</a></li>
@endif
@endif
<li class="breadcrumb-item active">Create Thread</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Create New Thread</h1>
</div>
<div class="card-body">
<form action="{{ route('forum.threads.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="category_id" class="form-label">Category</label>
<select class="form-select bg-dark text-white @error('category_id') is-invalid @enderror" id="category_id" name="category_id" required>
<option value="">Select a category</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id', $category_id) == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="title" class="form-label">Thread Title</label>
<input type="text" class="form-control bg-dark text-white @error('title') is-invalid @enderror" id="title" name="title" value="{{ old('title') }}" required>
@error('title')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="content" class="form-label">Initial Post Content</label>
<textarea class="form-control bg-dark text-white @error('content') is-invalid @enderror" id="content" name="content" rows="10" required>{{ old('content') }}</textarea>
<div class="form-text text-muted">This will be the first topic in your thread.</div>
@error('content')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Create Thread</button>
@if(isset($category_id) && $category)
<a href="{{ route('forum.categories.show', $category) }}" class="btn btn-outline-light">Cancel</a>
@else
<a href="{{ route('forum.index') }}" class="btn btn-outline-light">Cancel</a>
@endif
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,86 @@
@extends('layouts.app')
@section('title', 'Edit Thread - 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">Edit</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Edit Thread</h1>
</div>
<div class="card-body">
<form action="{{ route('forum.threads.update', $thread) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="category_id" class="form-label">Category</label>
<select class="form-select bg-dark text-white @error('category_id') is-invalid @enderror" id="category_id" name="category_id" required>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id', $thread->category_id) == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="title" class="form-label">Thread Title</label>
<input type="text" class="form-control bg-dark text-white @error('title') is-invalid @enderror" id="title" name="title" value="{{ old('title', $thread->title) }}" required>
@error('title')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
@if(isset($initialTopic))
<div class="mb-3">
<label for="content" class="form-label">Initial Post Content</label>
<textarea class="form-control bg-dark text-white @error('content') is-invalid @enderror" id="content" name="content" rows="10" required>{{ old('content', $initialTopic->content) }}</textarea>
@error('content')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
@endif
@if(auth()->user()->hasRole('admin'))
<div class="row mb-3">
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="is_sticky" name="is_sticky" value="1" {{ old('is_sticky', $thread->is_sticky) ? 'checked' : '' }}>
<label class="form-check-label" for="is_sticky">
Sticky Thread
</label>
<div class="form-text text-muted">Sticky threads appear at the top of the category.</div>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="is_locked" name="is_locked" value="1" {{ old('is_locked', $thread->is_locked) ? 'checked' : '' }}>
<label class="form-check-label" for="is_locked">
Lock Thread
</label>
<div class="form-text text-muted">Locked threads cannot receive new topics or posts.</div>
</div>
</div>
</div>
@endif
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Update Thread</button>
<a href="{{ route('forum.threads.show', $thread) }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,195 @@
@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
@@ -0,0 +1,47 @@
@extends('layouts.app')
@section('title', 'Create Topic - 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">Create Topic</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Create New Topic</h1>
<p class="text-muted mb-0">in thread: {{ $thread->title }}</p>
</div>
<div class="card-body">
<form action="{{ route('forum.topics.store') }}" method="POST">
@csrf
<input type="hidden" name="thread_id" value="{{ $thread->id }}">
<div class="mb-3">
<label for="title" class="form-label">Topic Title</label>
<input type="text" class="form-control bg-dark text-white @error('title') is-invalid @enderror" id="title" name="title" value="{{ old('title') }}" required>
@error('title')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="content" class="form-label">Content</label>
<textarea class="form-control bg-dark text-white @error('content') is-invalid @enderror" id="content" name="content" rows="10" required>{{ old('content') }}</textarea>
@error('content')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Create Topic</button>
<a href="{{ route('forum.threads.show', $thread) }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,61 @@
@extends('layouts.app')
@section('title', 'Edit Topic - 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"><a href="{{ route('forum.topics.show', $topic) }}" class="text-decoration-none">{{ $topic->title }}</a></li>
<li class="breadcrumb-item active">Edit</li>
</ol>
</nav>
<div class="card bg-dark text-white">
<div class="card-header">
<h1 class="h3 mb-0">Edit Topic</h1>
<p class="text-muted mb-0">in thread: {{ $thread->title }}</p>
</div>
<div class="card-body">
<form action="{{ route('forum.topics.update', $topic) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="title" class="form-label">Topic Title</label>
<input type="text" class="form-control bg-dark text-white @error('title') is-invalid @enderror" id="title" name="title" value="{{ old('title', $topic->title) }}" required>
@error('title')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="content" class="form-label">Content</label>
<textarea class="form-control bg-dark text-white @error('content') is-invalid @enderror" id="content" name="content" rows="10" required>{{ old('content', $topic->content) }}</textarea>
@error('content')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
@if(auth()->user()->hasRole('admin'))
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="is_pinned" name="is_pinned" value="1" {{ old('is_pinned', $topic->is_pinned) ? 'checked' : '' }}>
<label class="form-check-label" for="is_pinned">
Pin Topic
</label>
<div class="form-text text-muted">Pinned topics appear at the top of the thread.</div>
</div>
</div>
@endif
<div class="d-flex gap-2">
<button type="submit" class="btn btn-gradient">Update Topic</button>
<a href="{{ route('forum.topics.show', $topic) }}" class="btn btn-outline-light">Cancel</a>
</div>
</form>
</div>
</div>
</div>
@endsection
+246
View File
@@ -0,0 +1,246 @@
@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