progress
This commit is contained in:
@@ -15,7 +15,12 @@ class ThreadsController extends Controller
|
||||
$category = Category::where('slug', $categorySlug)->first();
|
||||
$thread = Thread::where('slug', $threadSlug)->first();
|
||||
|
||||
$topics = Topic::where('category_id', $category->id)
|
||||
if (!$category || !$thread) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$topics = Topic::with('author')
|
||||
->where('category_id', $category->id)
|
||||
->where('thread_id', $thread->id)
|
||||
->paginate(15);
|
||||
|
||||
|
||||
@@ -16,14 +16,24 @@ class TopicsController extends Controller
|
||||
public function show(string $categorySlug, string $threadSlug, string $topicSlug)
|
||||
{
|
||||
$thread = Thread::with('category')->where('slug', $threadSlug)->first();
|
||||
$topic = Topic::where('slug', $topicSlug)->first();
|
||||
$topic = Topic::with('author')->where('slug', $topicSlug)->first();
|
||||
|
||||
if (!$topic || !$thread) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$topic->views_no = $topic->views_no+1;
|
||||
$topic->save();
|
||||
|
||||
$posts = Post::with('author')->where('topic_id', $topic->id)->paginate(15);
|
||||
|
||||
return view('forum.topics.show', compact('thread', 'topic', 'posts'));
|
||||
// Get similar topics from the same thread
|
||||
$similarTopics = Topic::where('thread_id', $thread->id)
|
||||
->where('id', '!=', $topic->id)
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
return view('forum.topics.show', compact('thread', 'topic', 'posts', 'similarTopics'));
|
||||
}
|
||||
|
||||
public function create(string $categorySlug, string $threadSlug)
|
||||
|
||||
@@ -21,4 +21,9 @@ class Topic extends Model
|
||||
'views_no',
|
||||
'replies_no',
|
||||
];
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ $(".my-rating").starRating({
|
||||
}
|
||||
});
|
||||
|
||||
$('.mark-as-seen-btn').on('click', function (e) {
|
||||
$('.mark-action').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
let url = '/lists/' + $(this).data('list') + '/' + $(this).data('id') + '/' + $(this).data('type');
|
||||
var self = this
|
||||
@@ -72,7 +72,7 @@ $('.mark-as-seen-btn').on('click', function (e) {
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.like-btn').on('click', function (e) {
|
||||
$('.like-action').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
let url = '/lists/' + $(this).data('list') + '/' + $(this).data('id') + '/' + $(this).data('type');
|
||||
var self = this
|
||||
|
||||
@@ -4,35 +4,38 @@
|
||||
<div class="container-fluid threads-page">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-10 forums">
|
||||
<div class="thread-info">
|
||||
<div class="card category">
|
||||
<div class="card-header">
|
||||
<h1 class="title">
|
||||
<div class="row">
|
||||
<div class="col-md-10">
|
||||
<h1>{{ $thread->name }}</h1>
|
||||
{{ $thread->name }}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<a href="{{ route('forums.thread.topics.create', [$category->slug, $thread->slug]) }}" class="btn btn-primary">
|
||||
<a href="{{ route('forums.thread.topics.create', [$category->slug ?? 'unknown', $thread->slug]) }}" class="btn btn-primary">
|
||||
New topic
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{{ $thread->description }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="topics-list">
|
||||
<div class="card-body">
|
||||
@if($topics->count())
|
||||
<div class="forum-header">
|
||||
<div class="forum-header mb-3">
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<i class="fa fa-comments-o" aria-hidden="true"></i>
|
||||
<span class="iconify" data-icon="mdi-comment-text-outline"></span>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
Topic Name / Author
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
Views
|
||||
Stats
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
Last post
|
||||
@@ -40,49 +43,72 @@
|
||||
</div>
|
||||
</div>
|
||||
@foreach($topics as $topic)
|
||||
<div class="topic-row">
|
||||
<div class="topic-row mb-3">
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<i class="fa fa-comments-o" aria-hidden="true"></i>
|
||||
<div class="col-md-1 text-center">
|
||||
<span class="iconify" data-icon="mdi-comment-text-outline"></span>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<a href="{{ route('forums.thread.topics.show', [$category->slug, $thread->slug, $topic->slug]) }}">{{ $topic->name }}</a> <br>
|
||||
<small>Creator</small>
|
||||
<a href="{{ route('forums.thread.topics.show', [$category->slug ?? 'unknown', $thread->slug, $topic->slug]) }}">{{ $topic->name }}</a> <br>
|
||||
<small>Created by {{ $topic->author->name ?? 'Unknown User' }} {{ $topic->created_at ? $topic->created_at->diffForHumans() : 'N/A' }}</small>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<span title="Views"><i class="fa fa-eye"></i> {{ $topic->views_no }}</span>
|
||||
<span title="Replies"><i class="fa fa-pencil"></i> {{ $topic->replies_no }}</span>
|
||||
<span title="Views"><span class="iconify me-1" data-icon="mdi-eye"></span> {{ $topic->views_no }}</span><br>
|
||||
<span title="Replies"><span class="iconify me-1" data-icon="mdi-message-text"></span> {{ $topic->replies_no }}</span>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
last
|
||||
<small>{{ $topic->updated_at ? $topic->updated_at->diffForHumans() : 'N/A' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if(!$loop->last)
|
||||
<hr>
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
<div class="no-topics">
|
||||
There are no topics at the moment! Go ahead, <a href="{{ route('forums.thread.topics.create', [$category->slug, $thread->slug]) }}">post</a> the first one!
|
||||
<div class="no-topics text-center p-4">
|
||||
<p>There are no topics at the moment!</p>
|
||||
<a href="{{ route('forums.thread.topics.create', [$category->slug ?? 'unknown', $thread->slug]) }}" class="btn btn-primary">Create the first topic</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
{{ $topics->links() }}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="card">
|
||||
<div class="user-actions">
|
||||
<ul>
|
||||
<li>
|
||||
<a href=""><span class="iconify" data-icon="mdi-eye-check-outline"></span> Mark as seen</a>
|
||||
<div class="card-header">
|
||||
<h5>Thread Actions</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-2">
|
||||
<a href="#"><span class="iconify me-1" data-icon="mdi-eye-check-outline"></span> Mark as seen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href=""><span class="iconify" data-icon="mdi-thumb-up-outline"></span> Like</a>
|
||||
<li class="mb-2">
|
||||
<a href="#"><span class="iconify me-1" data-icon="mdi-thumb-up-outline"></span> Like</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href=""><span class="iconify" data-icon="mdi-playlist-check"></span> add to list</a>
|
||||
<li class="mb-2">
|
||||
<a href="#"><span class="iconify me-1" data-icon="mdi-playlist-check"></span> Add to list</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h5>Thread Stats</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-2">
|
||||
<span class="iconify me-1" data-icon="mdi-comment-text-multiple-outline"></span>
|
||||
Topics: {{ $topics->total() }}
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<span class="iconify me-1" data-icon="mdi-clock-outline"></span>
|
||||
Created: {{ $thread->created_at ? $thread->created_at->diffForHumans() : 'N/A' }}
|
||||
</li>
|
||||
</ul>
|
||||
<hr>
|
||||
rate
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{{ $topic->name }} <br>
|
||||
<small>Created by {{ $topic->author->name }} | {{ $topic->created_at->diffForHumans() }}</small>
|
||||
<small>Created by {{ $topic->author->name ?? 'Unknown User' }} | {{ $topic->created_at ? $topic->created_at->diffForHumans() : 'N/A' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</h1>
|
||||
@@ -20,13 +20,17 @@
|
||||
<div class="row post-row">
|
||||
<div class="col-md-1">
|
||||
<div class="text-center">
|
||||
<img src="{{ $post->author->avatar ?? 'https://ui-avatars.com/api/?name=' . urlencode($post->author->name) }}"
|
||||
alt="{{ $post->author->name }}"
|
||||
@php
|
||||
$authorName = $post->author->name ?? 'Unknown User';
|
||||
$avatarUrl = $post->author->avatar ?? 'https://ui-avatars.com/api/?name=' . urlencode($authorName);
|
||||
@endphp
|
||||
<img src="{{ $avatarUrl }}"
|
||||
alt="{{ $authorName }}"
|
||||
class="rounded-circle"
|
||||
width="64"
|
||||
height="64">
|
||||
<div class="mt-2">
|
||||
<small>{{ $post->author->name }}</small>
|
||||
<small>{{ $authorName }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,7 +39,7 @@
|
||||
{!! $post->content !!}
|
||||
</div>
|
||||
<div class="post-meta">
|
||||
<small>Posted {{ $post->created_at->diffForHumans() }}</small>
|
||||
<small>Posted {{ $post->created_at ? $post->created_at->diffForHumans() : 'N/A' }}</small>
|
||||
<div class="float-end">
|
||||
<a href="#" class="btn btn-primary btn-sm">Reply</a>
|
||||
<a href="#" class="btn btn-secondary btn-sm">Like</a>
|
||||
@@ -51,7 +55,7 @@
|
||||
</div>
|
||||
{{ $posts->links() }}
|
||||
<hr>
|
||||
<form action="{{ route('forums.thread.topics.post.store', [$thread->category->slug, $thread->slug, $topic->slug]) }}" method="POST">
|
||||
<form action="{{ route('forums.thread.topics.post.store', [$thread->category->slug ?? 'unknown', $thread->slug, $topic->slug]) }}" method="POST">
|
||||
@csrf
|
||||
<div class="form-group">
|
||||
<x-easy-mde name="content" />
|
||||
@@ -80,7 +84,7 @@
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<span class="iconify me-1" data-icon="mdi-clock-outline"></span>
|
||||
Created: {{ $topic->created_at->diffForHumans() }}
|
||||
Created: {{ $topic->created_at ? $topic->created_at->diffForHumans() : 'N/A' }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -93,8 +97,8 @@
|
||||
<ul class="list-unstyled">
|
||||
@foreach($similarTopics as $similarTopic)
|
||||
<li class="mb-2">
|
||||
<a href="{{ route('forums.thread.topics.show', [$thread->category->slug, $thread->slug, $similarTopic->slug]) }}">
|
||||
{{ $similarTopic->name }}
|
||||
<a href="{{ route('forums.thread.topics.show', [$thread->category->slug ?? 'unknown', $thread->slug, $similarTopic->slug]) }}">
|
||||
{{ $similarTopic->name ?? 'Unnamed Topic' }}
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
|
||||
@@ -246,20 +246,40 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="user-actions">
|
||||
<a href="#" class="d-block mb-3 text-decoration-none mark-as-seen-btn {{ auth()->check() ? ($movie->wasListedBy('watched', auth()->user()) ? 'seen' : '') : '' }}"
|
||||
@if(auth()->check())
|
||||
<a href="#" class="d-block mb-3 text-decoration-none mark-as-seen-btn mark-action {{ auth()->check() ? ($movie->wasListedBy('watched', auth()->user()) ? 'seen' : '') : '' }}"
|
||||
data-id="{{ $movie->id }}"
|
||||
data-type="movie"
|
||||
data-list="watched">
|
||||
<span class="iconify me-1" data-icon="mdi-eye-check-outline"></span>
|
||||
Mark as seen
|
||||
</a>
|
||||
<a href="#" class="d-block mb-3 text-decoration-none like-btn {{ auth()->check() ? ($movie->wasListedBy('liked', auth()->user()) ? 'liked' : '') : '' }}"
|
||||
@else
|
||||
<a href="{{ route('login') }}?msg=login-to-watch" class="d-block mb-3 text-decoration-none mark-as-seen-btn"
|
||||
data-id="{{ $movie->id }}"
|
||||
data-type="movie"
|
||||
data-list="watched">
|
||||
<span class="iconify me-1" data-icon="mdi-eye-check-outline"></span>
|
||||
Mark as seen
|
||||
</a>
|
||||
@endif
|
||||
@if(auth()->check())
|
||||
<a href="#" class="d-block mb-3 text-decoration-none like-btn like-action {{ auth()->check() ? ($movie->wasListedBy('liked', auth()->user()) ? 'liked' : '') : '' }}"
|
||||
data-id="{{ $movie->id }}"
|
||||
data-type="movie"
|
||||
data-list="liked">
|
||||
<span class="iconify me-1" data-icon="mdi-thumb-up-outline"></span>
|
||||
Like
|
||||
</a>
|
||||
@else
|
||||
<a href="#" class="d-block mb-3 text-decoration-none like-btn"
|
||||
data-id="{{ $movie->id }}"
|
||||
data-type="movie"
|
||||
data-list="liked">
|
||||
<span class="iconify me-1" data-icon="mdi-thumb-up-outline"></span>
|
||||
Like
|
||||
</a>
|
||||
@endif
|
||||
<a href="#" class="d-block mb-3 text-decoration-none add-to-list-btn">
|
||||
<span class="iconify me-1" data-icon="mdi-playlist-check"></span>
|
||||
Add to list
|
||||
|
||||
Reference in New Issue
Block a user