Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $messages = $this->posts->validForCreation(Input::get('title'), Input::get('slug'));
     if (count($messages) > 0) {
         return Response::json($messages->all(), 400);
     }
     $date = Input::get('publish_date') == "" ? "Now" : Input::get('publish_date');
     return $this->posts->create(Input::get('title'), Input::get('content'), Input::get('slug'), explode(',', Input::get('tags')), (bool) Input::get('active'), Input::get('user_id', Auth::user()->id), Carbon::createFromTimestamp(strtotime($date)));
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $messages = $this->posts->validForCreation(Input::get('title'));
     if (count($messages) > 0) {
         return Response::json($messages->all(), 400);
     }
     $date = Input::get('publish_date') == "" ? "Now" : Input::get('publish_date');
     $post = $this->posts->create(['title' => Input::get('title'), 'content' => Input::get('content'), 'link_url' => Input::get('link_url'), 'type' => Input::get('type', 'text'), 'image' => Input::get('image', ''), 'tags' => explode(',', Input::get('tags')), 'active' => (bool) Input::get('active'), 'user_id' => Input::get('user_id', Auth::user()->id), 'publish_date' => Carbon::createFromTimestamp(strtotime($date))]);
     return (string) $this->posts->find($post->id);
 }