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