Exemplo n.º 1
0
 public function store(HttpRequest $request, $forum_id)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     $forum = Forum::findOrFail($forum_id);
     $this->authorizePost($forum, null);
     $topic = Topic::createNew(['forum' => $forum, 'title' => $request->input('title'), 'poster' => Auth::user(), 'body' => $request->input('body'), 'notifyReplies' => false, 'cover' => TopicCover::findForUse(presence($request->input('cover_id')), Auth::user())]);
     Event::fire(new TopicWasCreated($topic, $topic->posts->last(), Auth::user()));
     return ujs_redirect(route('forum.topics.show', $topic));
 }
Exemplo n.º 2
0
 public function store(HttpRequest $request, $forum_id)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     $forum = Forum::findOrFail($forum_id);
     $this->authorizePost($forum, null);
     $topic = Topic::createNew($forum, $request->input('title'), Auth::user(), $request->input('body'), false)->fresh();
     Event::fire(new TopicWasCreated($topic, $topic->posts->last(), Auth::user()));
     return ujs_redirect(route('forum.topics.show', $topic));
 }
Exemplo n.º 3
0
 public function store()
 {
     if (Request::hasFile('cover_file') !== true) {
         abort(422);
     }
     $forum = Forum::findOrFail(Request::input('forum_id'));
     if ($forum->cover !== null) {
         abort(422);
     }
     try {
         $cover = ForumCover::upload(Request::file('cover_file')->getRealPath(), Auth::user(), $forum);
     } catch (ImageProcessorException $e) {
         return error_popup($e->getMessage());
     }
     return fractal_item_array($cover, new ForumCoverTransformer());
 }
Exemplo n.º 4
0
 public function store(HttpRequest $request)
 {
     $forum = Forum::findOrFail($request->get('forum_id'));
     priv_check('ForumTopicStore', $forum)->ensureCan();
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     if (get_bool($request->get('with_poll'))) {
         $pollParams = get_params($request, 'forum_topic_poll', ['length_days:int', 'max_options:int', 'options:string_split', 'title', 'vote_change:bool']);
         $poll = (new TopicPoll())->fill($pollParams);
         if (!$poll->isValid()) {
             return error_popup(implode(' ', $poll->validationErrors()->allMessages()));
         }
     }
     $params = ['title' => $request->get('title'), 'user' => Auth::user(), 'body' => $request->get('body'), 'cover' => TopicCover::findForUse(presence($request->input('cover_id')), Auth::user())];
     $topic = Topic::createNew($forum, $params, $poll ?? null);
     if ($topic->topic_id !== null) {
         Event::fire(new TopicWasCreated($topic, $topic->posts->last(), Auth::user()));
         return ujs_redirect(route('forum.topics.show', $topic));
     } else {
         abort(422);
     }
 }