postRepo = $postRepo; } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { try { $response = $this->postRepo->getAllPosts(); $this->updateStatusCode($response); return $this->respond($response); } catch (\Exception $ex) { Log::error($ex); return $this->respondInternalError(trans('api.something_went_wrong')); } } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \App\Http\Requests\StorePostRequest $request * @return \Illuminate\Http\Response */ public function store(StorePostRequest $request) { try { $response = $this->postRepo->storePost($request->all()); $this->updateStatusCode($response); return $this->respond($response); } catch (\Exception $ex) { Log::error($ex); return $this->respondInternalError(trans('api.something_went_wrong')); } } /** * Display the specified resource. * * @param \App\Models\Post $post * @return \Illuminate\Http\Response */ public function show(Post $post) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\Post $post * @return \Illuminate\Http\Response */ public function edit(Post $post) { // } /** * Update the specified resource in storage. * * @param \App\Http\Requests\UpdatePostRequest $request * @param \App\Models\Post $post * @return \Illuminate\Http\Response */ public function update(UpdatePostRequest $request, Post $post) { try { $response = $this->postRepo->updatePost($request->all(), $post); $this->updateStatusCode($response); return $this->respond($response); } catch (\Exception $ex) { Log::error($ex); return $this->respondInternalError(trans('api.something_went_wrong')); } } /** * Remove the specified resource from storage. * * @param \App\Models\Post $post * @return \Illuminate\Http\Response */ public function destroy(Post $post) { // } }