Пример #1
0
 /**
  * Store a new post.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     $input = array_merge(['user_id' => Credentials::getuser()->id], Binput::only(['title', 'summary', 'body']));
     $val = PostRepository::validate($input, array_keys($input));
     if ($val->fails()) {
         return Redirect::route('blog.posts.create')->withInput()->withErrors($val->errors());
     }
     $post = PostRepository::create($input);
     return Redirect::route('blog.posts.show', ['posts' => $post->id])->with('success', 'Your post has been created successfully.');
 }
Пример #2
0
 /**
  * Store a new page.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     $input = array_merge($this->getInput(), ['user_id' => Credentials::getuser()->id]);
     $val = PageRepository::validate($input, array_keys($input));
     if ($val->fails()) {
         return Redirect::route('pages.create')->withInput()->withErrors($val->errors());
     }
     $page = PageRepository::create($input);
     // write flash message and redirect
     return Redirect::route('pages.show', ['pages' => $page->slug])->with('success', 'Your page has been created successfully.');
 }
Пример #3
0
 /**
  * Store a new event.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     $input = array_merge(['user_id' => Credentials::getuser()->id], Binput::only(['title', 'location', 'date', 'body']));
     $val = EventRepository::validate($input, array_keys($input));
     if ($val->fails()) {
         return Redirect::route('events.create')->withInput()->withErrors($val->errors());
     }
     $input['date'] = Carbon::createFromFormat(Config::get('date.php_format'), $input['date']);
     $event = EventRepository::create($input);
     return Redirect::route('events.show', ['events' => $event->id])->with('success', 'Your event has been created successfully.');
 }
Пример #4
0
 /**
  * Store a new comment.
  *
  * @param int $postId
  *
  * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function store($postId)
 {
     $input = array_merge(Binput::only('body'), ['user_id' => Credentials::getuser()->id, 'post_id' => $postId, 'version' => 1]);
     if (CommentRepository::validate($input, array_keys($input))->fails()) {
         throw new BadRequestHttpException('Your comment was empty.');
     }
     $this->throttler->hit();
     $comment = CommentRepository::create($input);
     $contents = View::make('posts.comment', ['comment' => $comment, 'post_id' => $postId]);
     return Response::json(['success' => true, 'msg' => 'Comment created successfully.', 'contents' => $contents->render(), 'comment_id' => $comment->id], 201);
 }