$app->flash('error', 'Your thread could not be created.'); return $app->response->redirect($app->urlFor('forum.category', ['id' => $categoryID])); } } $app->render('forum/newthread.php', ['category' => $category, 'request' => $request, 'errors' => $v->errors()]); })->name('forum.thread.create.post'); $app->get('/forum/:id/thread/new', $authenticated(), function ($id) use($app) { $category = ForumCategory::find($id); if ($category == null) { $app->flash('error', 'Category was not found'); return $app->response->redirect($app->urlFor('forum.home')); } $app->render('forum/newthread.php', ['category' => $category]); })->name('forum.thread.create'); $app->get('/forum/thread/delete/:id', $modOrAdmin(), function ($id) use($app) { $thread = ForumThread::find($id); if (!$thread) { $app->flash('global', 'Unable to delete, thread not found.'); return $app->response->redirect($app->urlFor('forum.home')); } else { $delComments = $thread->comments(); $delCo = true; if ($delComments->count() > 0) { $delCo = $delComments->delete(); } if ($thread->delete() && $delCo) { $app->flash('success', 'The forum thread and all replies have been deleted.'); return $app->response->redirect($app->urlFor('forum.home')); } } })->name('forum.thread.delete');
public function validate_uniqueForumThread($value, $input, $args) { return !(bool) ForumThread::where('title', $value)->count(); }
public function countForumPosts() { return ForumComment::where('author_id', $this->id)->count() + ForumThread::where('author_id', $this->id)->count(); }