This commit is contained in:
2025-02-16 21:11:07 +02:00
parent 87bbfc33d3
commit e8d7e6a1c4
253 changed files with 3879 additions and 72 deletions
+47 -1
View File
@@ -3,9 +3,55 @@
namespace App\Http\Controllers\Forum;
use App\Http\Controllers\Controller;
use App\Http\Requests\Forum\PostRequest;
use App\Models\Forum\Post;
use App\Models\Forum\Thread;
use App\Models\Forum\Topic;
use Illuminate\Http\Request;
class PostsController extends Controller
{
//
public function create()
{
// full reply?
}
public function store(PostRequest $request, string $categorySlug, string $threadSlug, string $topicSlug)
{
$thread = Thread::with('category')->where('slug', $threadSlug)->first();
$topic = Topic::where('slug', $topicSlug)->first();
if ($topic->status == Topic::STATUS_CLOSED) {
abort(403);
}
Post::create([
'content' => $request->get('content'),
'user_id' => auth()->user()->id,
'category_id' => $thread->category->id,
'thread_id' => $thread->id,
'topic_id' => $topic->id,
]);
$topic->replies_no = $topic->replies_no+1;
$topic->save();
// redirect back, keep in mind pagination
return redirect()->back()->with('success', 'Reply posted!');
}
public function edit(int $id)
{
}
public function update(PostRequest $request, int $id)
{
}
public function destroy(int $id)
{
}
}
@@ -4,12 +4,76 @@ namespace App\Http\Controllers\Forum;
use App\Http\Controllers\Controller;
use App\Http\Requests\Forum\TopicRequest;
use App\Models\Forum\Category;
use App\Models\Forum\Post;
use App\Models\Forum\Thread;
use App\Models\Forum\Topic;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class TopicsController extends Controller
{
public function create(TopicRequest $request)
public function show(string $categorySlug, string $threadSlug, string $topicSlug)
{
return view('forum.topics.create');
$thread = Thread::with('category')->where('slug', $threadSlug)->first();
$topic = Topic::where('slug', $topicSlug)->first();
$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'));
}
public function create(string $categorySlug, string $threadSlug)
{
// check policy
$forumCategories = Category::get();
$forumThreads = Thread::get();
$currentThread = Thread::with('category')->where('slug', $threadSlug)->first();
return view('forum.topics.create', compact('forumCategories', 'forumThreads', 'currentThread'));
}
public function store(TopicRequest $request, string $categorySlug, string $threadSlug)
{
// check policy
$thread = Thread::with('category')->where('slug', $threadSlug)->first();
$topic = Topic::create([
'name' => $request->get('name'),
'slug' => Str::slug($request->get('name')),
'status' => Topic::STATUS_OPEN,
'category_id' => $thread->category->id,
'thread_id' => $thread->id,
'user_id' => auth()->user()->id,
]);
Post::create([
'content' => $request->get('content'),
'user_id' => auth()->user()->id,
'category_id' => $thread->category->id,
'thread_id' => $thread->id,
'topic_id' => $topic->id,
]);
return redirect()->route('forums.thread.topics.show', [$categorySlug, $threadSlug, $topic->slug]);
}
public function edit(string $categorySlug, string $threadSlug, string $topicSlug)
{
// check policy
}
public function update(TopicRequest $request)
{
// check policy
}
public function destroy()
{
// check policy
}
}
+16 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\Movie\CommentRequest;
use App\Models\Comment;
use App\Models\Movie;
use Illuminate\Http\Request;
@@ -31,7 +32,21 @@ class MovieController extends Controller
})
->paginate(15);
return view('movie.show', compact('movie', 'comments'));
}
public function storeComment(CommentRequest $request, string $movieSlug)
{
$movie = Movie::where('slug', $movieSlug)->firstOrFail();
Comment::create([
'entity_id' => $movie->id,
'entity_type' => Comment::TYPE_MOVIE,
'user_id' => auth()->user()->id,
'content' => $request->get('content'),
'published_at' => new \DateTime(),
]);
return redirect()->back()->with('success', 'Comment posted!');
}
}
+11 -1
View File
@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Models\MediaList;
use App\Models\MediaListItem;
use App\Models\User;
use Illuminate\Http\Request;
@@ -11,6 +13,14 @@ class ProfileController extends Controller
{
$user = User::where('slug', $slug)->first();
return view('profile.show', compact('user'));
$watchedList = MediaList::where('slug', MediaList::WATCHED)->first();
$lastWatchedListItem = MediaListItem::with('item')->where('media_list_id', $watchedList->id)
->orderBy('id', 'desc')
->first();
$lastWatched = $lastWatchedListItem->item;
return view('profile.show', compact('user', 'lastWatched'));
}
}
+4 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Season;
use App\Models\Show;
use Illuminate\Http\Request;
@@ -20,6 +21,8 @@ class ShowController extends Controller
$comments = [];
return view('show.show', compact('show', 'comments'));
$seasons = Season::where('show_id', $show->id)->orderBy('season_number', 'ASC')->get();
return view('show.show', compact('show', 'comments', 'seasons'));
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests\Forum;
use Illuminate\Foundation\Http\FormRequest;
class PostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'content' => 'required|min:2'
];
}
}
+3 -2
View File
@@ -11,7 +11,7 @@ class TopicRequest extends FormRequest
*/
public function authorize(): bool
{
return false;
return true;
}
/**
@@ -22,7 +22,8 @@ class TopicRequest extends FormRequest
public function rules(): array
{
return [
//
'name' => 'required|min:2|max:255',
'content' => 'required|min:2',
];
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests\Movie;
use Illuminate\Foundation\Http\FormRequest;
class CommentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'content' => 'required|min:2'
];
}
}
@@ -18,8 +18,6 @@ class Recommendations extends Component
public function mount()
{
$movie = Movie::find($this->movie->id);
$this->recommendations = Movie::whereIn('id', MovieRecommendation::where('movie_id', $this->movie->id)->pluck('recommended_movie_id'))->get();
}
}
+13
View File
@@ -2,12 +2,25 @@
namespace App\Livewire\MoviePage;
use App\Models\Movie;
use App\Models\MovieSimilar;
use Livewire\Component;
class Similar extends Component
{
public $movie;
public $similarMovies;
public function render()
{
return view('livewire.movie-page.similar');
}
public function mount()
{
$this->similarMovies = Movie::whereIn(
'id',
MovieSimilar::where('movie_id', $this->movie->id)->pluck('similar_movie_id')
)->get();
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Livewire\MoviePage\Tabs;
use App\Models\Movie;
use Livewire\Component;
class Videos extends Component
{
public $movie;
public $videos;
public function render()
{
return view('livewire.movie-page.tabs.videos');
}
public function mount()
{
$this->movie = Movie::with('videos')->where('id', $this->movie->id)->first();
$this->videos = $this->movie->videos;
}
}
+5
View File
@@ -21,4 +21,9 @@ class Comment extends Model
'tmdb_id',
'tmdb_url',
];
public function author()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
}
+15 -1
View File
@@ -2,9 +2,23 @@
namespace App\Models\Forum;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
//
protected $table = 'forum_posts';
protected $fillable = [
'content',
'user_id',
'category_id',
'thread_id',
'topic_id',
];
public function author()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
}
+5
View File
@@ -7,4 +7,9 @@ use Illuminate\Database\Eloquent\Model;
class Thread extends Model
{
protected $table = 'forum_threads';
public function category()
{
return $this->hasOne(Category::class, 'id', 'category_id');
}
}
+5
View File
@@ -8,6 +8,9 @@ class Topic extends Model
{
protected $table = 'forum_topics';
public const STATUS_OPEN = 'open';
public const STATUS_CLOSED = 'closed';
protected $fillable = [
'name',
'slug',
@@ -15,5 +18,7 @@ class Topic extends Model
'category_id',
'thread_id',
'user_id',
'views_no',
'replies_no',
];
}
+11
View File
@@ -58,6 +58,17 @@ class Movie extends Model
return $rating ? $rating->rate : null;
}
public function trailer()
{
return $this->belongsToMany(Video::class, 'movie_videos', 'movie_id', 'video_id')
->where('videos.type', 'Trailer');
}
public function externalIds()
{
return $this->hasOne(ExternalId::class, 'entity_id', 'id')->where('entity_type', ExternalId::TYPE_MOVIE);
}
public function director()
{
return $this->belongsToMany(Person::class, 'movie_cast', 'movie_id', 'person_id')
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Policies\Forum;
use App\Models\User;
class CreatePostPolicy
{
/**
* Create a new policy instance.
*/
public function __construct()
{
//
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Policies\Forum;
use App\Models\User;
class CreateTopicPolicy
{
/**
* Create a new policy instance.
*/
public function __construct()
{
//
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Policies\Forum;
use App\Models\User;
class DeletePostPolicy
{
/**
* Create a new policy instance.
*/
public function __construct()
{
//
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Policies\Forum;
use App\Models\User;
class DeleteTopicPolicy
{
/**
* Create a new policy instance.
*/
public function __construct()
{
//
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Policies\Forum;
use App\Models\User;
class EditPostPolicy
{
/**
* Create a new policy instance.
*/
public function __construct()
{
//
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Policies\Forum;
use App\Models\User;
class EditTopicPolicy
{
/**
* Create a new policy instance.
*/
public function __construct()
{
//
}
}