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