Post = $Post; $this->helpers = $helpers; } public function index(){ $data = $this->Post::with(['categories'])->listFrontEnd([ 'page' => input('page'), 'sort' => input('sort')??'published_at', 'perPage' => input('count'), 'search' => trim(input('search')), 'category' => input('category'), 'date' => input('date'), 'published' => true ]); return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); } public function show($id){ $data = $this->Post::with('categories')->find($id); if ($data){ return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]); } else { return $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']); } } }