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