Post = $Post; $this->helpers = $helpers; } public function index(){ $path = Config::get('app.cdn'); $data = $this->Post::with(['categories:id,name'])->listFrontEnd([ 'page' => input('page'), 'sort' => input('sort')??'published_at desc', 'perPage' => input('count'), 'search' => trim(input('search')), 'category' => input('category'), 'date' => input('date'), 'published' => true, 'select' => ['id','title','published_at','content_html',DB::raw("IF(featured_image<>'',concat('$path',featured_image),featured_image) as main_image")] ]); return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); } public function show($locale,$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']); } } }