public function countForumPosts() { return ForumComment::where('author_id', $this->id)->count(); }
if ($reply->save()) { $threadAuthor = $app->user->where('id', $thread->author_id)->first(); if ($threadAuthor) { $threadAuthor->notifications()->create(['body' => $app->auth->getFullNameOrUsername() . ' has replied to your thread.', 'user_id' => $app->auth->id]); } $app->flash('success', 'Your reply has been posted.'); return $app->response->redirect($app->urlFor('forum.thread', ['id' => $thread->id])); } else { $app->flash('error', 'There was an error posting your reply.'); return $app->response->redirect($app->urlFor('forum.thread', ['id' => $thread->id])); } } $category = $thread->category; $replies = $thread->comments()->get()->load('author'); $app->render('forum/thread.php', ['thread' => $thread->load('latestComment', 'author'), 'category' => $category, 'request' => $request, 'errors' => $v->errors(), 'threadmodal' => '#thread_form_modal', 'replies' => $replies]); })->name('forum.reply.create.post'); $app->get('/forum/reply/delete/:id', $modOrAdmin(), function ($id) use($app) { $reply = ForumComment::find($id); if (!$reply) { $app->flash('global', 'Unable to delete, reply not found.'); return $app->response->redirect($app->urlFor('forum.home')); } else { if ($reply->delete()) { $app->flash('success', 'The reply has been deleted.'); return $app->response->redirect($app->urlFor('forum.home')); } else { $app->flash('error', 'There was a problem deleting the reply.'); return $app->response->redirect($app->urlFor('forum.home')); } } })->name('forum.reply.delete');