repository = $job_listing; parent::__construct(); } /** * Show job_listing's list. * * @param string $slug * * @return response */ protected function index() { $job_listings = $this->repository ->setPresenter('\\Putup\\Joblisting\\Repositories\\Presenter\\JobListingListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $job_listings['code'] = 2000; return response()->json($job_listings) ->setStatusCode(200, 'INDEX_SUCCESS'); } /** * Show job_listing. * * @param string $slug * * @return response */ protected function show($slug) { $job_listing = $this->repository ->scopeQuery(function($query) use ($slug) { return $query->orderBy('id','DESC') ->where('slug', $slug); })->first(['*']); if (!is_null($job_listing)) { $job_listing = $this->itemPresenter($module, new JobListingItemTransformer); $job_listing['code'] = 2001; return response()->json($job_listing) ->setStatusCode(200, 'SHOW_SUCCESS'); } else { return response()->json([]) ->setStatusCode(400, 'SHOW_ERROR'); } } }