Example #1
0
 /**
  * Show a post preview.
  *
  * @param int $id
  *
  * @return Response
  */
 public function getPreview($id)
 {
     $post = $this->posts->find($id);
     if (!Auth::check() or !$post) {
         return App::abort(404, 'Page not found');
     }
     return View::make('themes.' . $this->theme . '.post', compact('post'));
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $messages = $this->posts->validForUpdate($id, Input::get('title'), Input::get('slug'));
     if (count($messages) > 0) {
         return Response::json($messages->all(), 400);
     }
     $post = $this->posts->update($id, Input::get('title'), Input::get('content'), Input::get('slug'), explode(',', Input::get('tags')), (bool) Input::get('active'), (int) Input::get('user_id'), Carbon::createFromTimestamp(strtotime(Input::get('publish_date'))));
     return (string) $this->posts->find($id);
 }
Example #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $messages = $this->posts->validForUpdate($id, 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');
     $this->posts->update(['id' => $id, 'title' => Input::get('title'), 'content' => Input::get('content'), 'link_url' => Input::get('link_url'), 'type' => Input::get('type'), '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($id);
 }
Example #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     return (string) $this->posts->find($id);
 }