From 2e3a97c09d8094e05f90e30a40a6116fe3fc9ff8 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Fri, 19 Dec 2025 15:45:00 +0800 Subject: [PATCH] Add post creation and display features Implemented post creation form with multiple content types. Added detailed post view with nested comment threading. --- resources/views/partials/comment.blade.php | 80 +++++++++++++++++++ resources/views/posts/create.blade.php | 88 +++++++++++++++++++++ resources/views/posts/show.blade.php | 89 ++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 resources/views/partials/comment.blade.php create mode 100644 resources/views/posts/create.blade.php create mode 100644 resources/views/posts/show.blade.php diff --git a/resources/views/partials/comment.blade.php b/resources/views/partials/comment.blade.php new file mode 100644 index 0000000..491f0ee --- /dev/null +++ b/resources/views/partials/comment.blade.php @@ -0,0 +1,80 @@ +
+
+
+
+ @auth +
+ @csrf + + +
+ @else + + @endauth + + + {{ $comment->votes }} + + + @auth +
+ @csrf + + +
+ @else + + @endauth +
+ +
+
+ u/{{ $comment->user->name }} + • {{ $comment->created_at->diffForHumans() }} +
+

{{ $comment->content }}

+ + @auth +
+ + @if($comment->user_id === auth()->id()) +
+ @csrf + @method('DELETE') + +
+ @endif +
+ + + @endauth +
+
+ + @foreach($comment->replies as $reply) + @include('partials.comment', ['comment' => $reply, 'depth' => $depth + 1]) + @endforeach +
+
+ +@if($depth === 0) + +@endif diff --git a/resources/views/posts/create.blade.php b/resources/views/posts/create.blade.php new file mode 100644 index 0000000..ee11b41 --- /dev/null +++ b/resources/views/posts/create.blade.php @@ -0,0 +1,88 @@ +@extends('layout') + +@section('title', 'Create Post') + +@section('content') +
+

Create a Post

+ +
+ @csrf + +
+ + + @error('community_id') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('type') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('title') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('content') +

{{ $message }}

+ @enderror +
+ + + + +
+
+ + +@endsection diff --git a/resources/views/posts/show.blade.php b/resources/views/posts/show.blade.php new file mode 100644 index 0000000..cbf56ad --- /dev/null +++ b/resources/views/posts/show.blade.php @@ -0,0 +1,89 @@ +@extends('layout') + +@section('title', $post->title) + +@section('content') +
+
+
+
+ @auth +
+ @csrf + + +
+ @else + + @endauth + + + {{ $post->votes }} + + + @auth +
+ @csrf + + +
+ @else + + @endauth +
+ +
+
+ r/{{ $post->community->name }} + • Posted by u/{{ $post->user->name }} + • {{ $post->created_at->diffForHumans() }} +
+

{{ $post->title }}

+ @if($post->content) +

{{ $post->content }}

+ @endif + @if($post->url) + {{ $post->url }} + @endif + + @auth + @if($post->user_id === auth()->id()) +
+ @csrf + @method('DELETE') + +
+ @endif + @endauth +
+
+
+ + @auth +
+

Add a Comment

+
+ @csrf + + @error('content') +

{{ $message }}

+ @enderror + +
+
+ @endauth + +
+

Comments ({{ $post->comments->count() }})

+ + @forelse($post->comments->whereNull('parent_id') as $comment) + @include('partials.comment', ['comment' => $comment, 'depth' => 0]) + @empty +

No comments yet. Be the first to comment!

+ @endforelse +
+
+@endsection