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