/** * Stores a post * * @param int The id of the thread */ public function store($id) { $forumPost = new ForumPost(Input::all()); $forumPost->creator_id = user()->id; $forumPost->thread_id = $id; $forumThread = ForumThread::isAccessible()->findOrFail($id); if ($forumThread->closed) { $this->alertError(trans('forums::closed_info')); return; } $valid = $forumPost->save(); if (!$valid) { return Redirect::to('forums/threads/create')->withInput()->withErrors($forumPost->getErrors()); } $forumThread->posts_count++; $forumThread->forceSave(); $user = user(); $user->posts_count++; $user->save(); $this->alertFlash(trans('app.created', ['Post'])); return Redirect::to($forumPost->paginatedPostUrl()); }
public function render($parameters = array()) { $limit = isset($parameters['limit']) ? (int) $parameters['limit'] : self::LIMIT; $forumThreads = ForumThread::isAccessible()->orderBy('forum_threads.updated_at', 'DESC')->take($limit)->get(); return View::make('forums::widget_latest_threads', compact('forumThreads'))->render(); }
public function globalSearch($subject) { $forumThreads = ForumThread::isAccessible()->where('forum_threads.title', 'LIKE', '%' . $subject . '%')->get(); $results = array(); foreach ($forumThreads as $forumThread) { $results[$forumThread->title] = URL::to('forums/threads/' . $forumThread->id . '/' . $forumThread->slug); } return $results; }
public function render($parameters = array()) { $forumThreads = ForumThread::isAccessible()->orderBy('forum_threads.updated_at', 'DESC')->take(5)->get(); return View::make('forums::widget_latest_threads', compact('forumThreads'))->render(); }