/** * increase share count * * @param $postId * * @return \Illuminate\Contracts\Routing\ResponseFactory|mixed */ public function share($postId) { if (!$this->post->find($postId)) { return $this->response->errorWrongArgs(); } if ($post = $this->post->increaseShareCount($postId, 1)) { return $this->response->withArray(['status' => 'success']); } return $this->response->errorInternalError(); }
/** * Update the specified resource in storage. * * @param int $id * @param PostRequest $request * * @return Response */ public function update($id, PostRequest $request) { $post = $this->post->find($id); if (is_null($post)) { return redirect()->route('post.index')->with('error', 'Post not found.'); } if ($this->post->update($id, $request->all())) { return redirect()->route('post.index', getQueryParams($request->fullUrl()))->with('success', 'Post successfully updated!'); } return redirect('post')->with('error', 'Problem updating Post!'); }