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