Beispiel #1
0
 public function validate_uniqueForumGroup($value, $input, $args)
 {
     return !(bool) ForumGroup::where('title', $value)->count();
 }
Beispiel #2
0
        $group->title = $name;
        $group->author_id = $app->auth->id;
        if ($group->save()) {
            $app->flash('success', 'Forum group created successfully.');
            return $app->response->redirect($app->urlFor('forum.home'));
        } else {
            $app->flash('error', 'There was an error creating the forum group.');
            return $app->response->redirect($app->urlFor('forum.home'));
        }
    }
    $groups = ForumGroup::all();
    $categories = ForumCategory::all();
    $app->render('forum/index.php', ['groups' => $groups, 'categories' => $categories, 'request' => $request, 'errors' => $v->errors(), 'modal' => '#group_form_modal']);
})->name('forum.group.create');
$app->get('/forum/group/delete/:id', $admin(), function ($id) use($app) {
    $group = ForumGroup::find($id);
    if (!$group) {
        $app->flash('global', 'Unable to delete, group not found.');
        return $app->response->redirect($app->urlFor('forum.home'));
    } else {
        $delCategories = $group->categories();
        $delThreads = $group->threads();
        $delComments = $group->comments();
        $delCa = true;
        $delCo = true;
        $delT = true;
        if ($delCategories->count() > 0) {
            $delCa = $delCategories->delete();
        }
        if ($delComments->count() > 0) {
            $delCo = $delComments->delete();
Beispiel #3
0
<?php

use Owency\Forum\ForumGroup;
use Owency\Forum\ForumCategory;
use Owency\Forum\ForumThread;
use Owency\Forum\ForumComment;
$app->group('/forum', function () use($app) {
    $app->get('/', function () use($app) {
        $groups = ForumGroup::all();
        $categories = ForumCategory::all()->load('latestComment', 'author');
        $app->render('forum/index.php', ['groups' => $groups->load('categories'), 'categories' => $categories->load('latestComment', 'author')]);
    })->name('forum.home');
    $app->get('/category/:id', 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'));
        }
        $threads = $category->threads->load('latestComment', 'author');
        $app->render('forum/category.php', ['category' => $category, 'threads' => $threads]);
    })->name('forum.category');
});
$app->get('/forum/thread/:id', $authenticated(), function ($id) use($app) {
    $thread = ForumThread::find($id);
    if ($thread == null) {
        $app->flash('global', 'That thread could not be found.');
        return $app->response->redirect($app->urlFor('home'));
    }
    $category = $thread->category;
    $replies = $thread->comments()->get()->load('author');
    $thread->increment('views');