Exemple #1
0
        $thread->body = $body;
        $thread->group_id = $category->group_id;
        $thread->category_id = $categoryID;
        $thread->author_id = $app->auth->id;
        if ($thread->save()) {
            $app->flash('success', 'Your thread has been created.');
            return $app->response->redirect($app->urlFor('forum.thread', ['id' => $thread->id]));
        } else {
            $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) {
Exemple #2
0
    if ($v->passes()) {
        $category = new ForumCategory();
        $category->title = $name;
        $category->description = $description;
        $category->author_id = $app->auth->id;
        if ($groupID != null) {
            $category->group_id = $groupID;
        }
        if ($categoryID) {
            $tempCat = ForumCategory::find($categoryID);
            $category->group_id = $tempCat->group_id;
        }
        if ($category->save()) {
            $app->flash('success', 'Forum category created successfully.');
            return $app->response->redirect($app->urlFor('forum.home'));
        } else {
            $app->flash('error', 'There was an error creating the forum category.');
            return $app->response->redirect($app->urlFor('forum.home'));
        }
    }
    if ($groupID) {
        $groups = ForumGroup::all();
        $categories = ForumCategory::all();
        $app->render('forum/index.php', ['groups' => $groups, 'categories' => $categories, 'request' => $request, 'errors' => $v->errors(), 'categorymodal' => '#category_form_modal']);
    }
    if ($categoryID) {
        $category = ForumCategory::find($categoryID);
        $threads = $category->threads()->get()->load('author');
        $app->render('forum/category.php', ['category' => $category, 'threads' => $threads, 'categorymodal' => '#category_form_modal', 'request' => $request, 'errors' => $v->errors()]);
    }
})->name('forum.category.create');