createNew() 공개 정적인 메소드

public static createNew ( $forum, $params, $poll = null )
예제 #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));
 }
예제 #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));
 }
예제 #3
0
 public function updatePage($text)
 {
     if ($this->userPage === null) {
         DB::transaction(function () use($text) {
             $topic = Forum\Topic::createNew(Forum\Forum::find(config('osu.user.user_page_forum_id')), "{$this->username}'s user page", $this, $text, false);
             $this->update(['userpage_post_id' => $topic->topic_first_post_id]);
         });
     } else {
         $this->userPage->edit($text, $this);
     }
     return $this->fresh();
 }
예제 #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);
     }
 }