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