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