middleware(function ($request, $next) { $this->form = AttendanceForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('bixo.employee.modules'), 'employee', guard_url('employee')); return $next($request); }); } /** * Display a list of attendance. * * @return Response */ public function index(AttendanceResourceRequest $request) { $request = $request->all(); $page = AttendanceActions::run('paginate', $request); $data = new AttendancesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('employee::attendance.names')) ->view('employee::attendance.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display attendance. * * @param Request $request * @param Model $attendance * * @return Response */ public function show(AttendanceResourceRequest $request, Attendance $model) { $form = $this->form; $modules = $this->modules; $data = new AttendanceResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('employee::attendance.name')) ->data(compact('data', 'form', 'modules')) ->view('employee::attendance.show') ->output(); } /** * Show the form for creating a new attendance. * * @param Request $request * * @return Response */ public function create(AttendanceResourceRequest $request, Attendance $model) { $form = $this->form; $modules = $this->modules; $data = new AttendanceResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('employee::attendance.name')) ->view('employee::attendance.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new attendance. * * @param Request $request * * @return Response */ public function store(AttendanceResourceRequest $request, Attendance $model) { try { $request = $request->all(); $model = AttendanceAction::run('store', $model, $request); $data = new AttendanceResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('employee::attendance.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('employee/attendance/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/employee/attendance')) ->redirect(); } } /** * Show attendance for editing. * * @param Request $request * @param Model $attendance * * @return Response */ public function edit(AttendanceResourceRequest $request, Attendance $model) { $form = $this->form; $modules = $this->modules; $data = new AttendanceResource($model); // return view('employee::attendance.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('employee::attendance.name')) ->view('employee::attendance.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the attendance. * * @param Request $request * @param Model $attendance * * @return Response */ public function update(AttendanceResourceRequest $request, Attendance $model) { try { $request = $request->all(); $model = AttendanceAction::run('update', $model, $request); $data = new AttendanceResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('employee::attendance.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('employee/attendance/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('employee/attendance/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the attendance. * * @param Model $attendance * * @return Response */ public function destroy(AttendanceResourceRequest $request, Attendance $model) { try { $request = $request->all(); $model = AttendanceAction::run('destroy', $model, $request); $data = new AttendanceResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('employee::attendance.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('employee/attendance/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('employee/attendance/' . $model->getRouteKey())) ->redirect(); } } }