diff --git a/app/Http/Controllers/ForumController.php b/app/Http/Controllers/ForumController.php index 595bf0ec..c4b24077 100644 --- a/app/Http/Controllers/ForumController.php +++ b/app/Http/Controllers/ForumController.php @@ -212,7 +212,7 @@ public function store(Request $request): RedirectResponse $validated = $request->validate([ 'title' => ['required', 'string', 'min:5', 'max:255', new CleanText], - 'body' => ['required', 'string', 'min:10', 'max:30000', new CleanText], + 'body' => ['nullable', 'string', 'max:30000', new CleanText], 'curriculum' => ['required', 'in:hsc,ssc'], 'subject_id' => ['nullable', 'exists:subjects,id'], 'node_id' => ['nullable', 'exists:nodes,id'], @@ -251,7 +251,7 @@ public function store(Request $request): RedirectResponse 'node_id' => $nodeId, 'curriculum' => $validated['curriculum'], 'title' => $validated['title'], - 'body' => $validated['body'], + 'body' => $validated['body'] ?? null, 'image_path' => $imagePath, 'is_locked' => false, 'moderation_status' => $moderationStatus, diff --git a/database/migrations/2026_09_01_231700_make_body_nullable_on_forum_posts_table.php b/database/migrations/2026_09_01_231700_make_body_nullable_on_forum_posts_table.php new file mode 100644 index 00000000..5a354fcd --- /dev/null +++ b/database/migrations/2026_09_01_231700_make_body_nullable_on_forum_posts_table.php @@ -0,0 +1,28 @@ +text('body')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('forum_posts', function (Blueprint $table) { + $table->text('body')->nullable(false)->change(); + }); + } +}; diff --git a/resources/js/pages/Forum/Create.vue b/resources/js/pages/Forum/Create.vue index c6d59a61..cc3aca08 100644 --- a/resources/js/pages/Forum/Create.vue +++ b/resources/js/pages/Forum/Create.vue @@ -121,7 +121,7 @@ const removeImage = () => { const handleOpenModal = () => { // Basic frontend checks before modal - if (!form.title.trim() || !form.body.trim()) { + if (!form.title.trim()) { form.post('/forum'); // trigger inertia validation errors if fields are empty return; @@ -335,14 +335,16 @@ const submit = () => { for="body" class="mb-2 block text-xs font-bold tracking-wider text-slate-700 uppercase dark:text-gray-300" > - Question Details * + Question Details + (Optional)
{{ post.body }}
diff --git a/resources/js/pages/Forum/Show.vue b/resources/js/pages/Forum/Show.vue
index e0e8e13d..66465bb7 100644
--- a/resources/js/pages/Forum/Show.vue
+++ b/resources/js/pages/Forum/Show.vue
@@ -86,7 +86,7 @@ interface ForumPost {
curriculum: 'hsc' | 'ssc';
title: string;
slug: string;
- body: string;
+ body?: string | null;
image_path?: string | null;
image_url?: string | null;
is_answered: boolean;
@@ -288,21 +288,21 @@ const openReportModal = (
id: number,
title: string | undefined,
authorName: string | undefined,
- contentPreview: string,
+ contentPreview?: string | null,
) => {
if (!requireAuth('Please sign in to report this content.')) {
return;
}
+ const preview = contentPreview || '';
+
reportingTarget.value = {
type,
id,
title,
authorName: authorName || 'Anonymous',
contentPreview:
- contentPreview.length > 200
- ? contentPreview.slice(0, 200) + '...'
- : contentPreview,
+ preview.length > 200 ? preview.slice(0, 200) + '...' : preview,
};
reportReason.value = 'Inappropriate content or conduct';
reportSuccessMessage.value = null;
@@ -581,7 +581,10 @@ function parseMentions(