repository = $emp_details; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\Empdetail\Repositories\Criteria\EmpDetailsResourceCriteria::class); } /** * Display a list of emp_details. * * @return Response */ public function index(EmpDetailsRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Empdetail\Repositories\Presenter\EmpDetailsPresenter::class) ->$function(); } $emp_details = $this->repository->paginate(); return $this->response->title(trans('empdetail::emp_details.names')) ->view('empdetail::emp_details.index', true) ->data(compact('emp_details')) ->output(); } /** * Display emp_details. * * @param Request $request * @param Model $emp_details * * @return Response */ public function show(EmpDetailsRequest $request, EmpDetails $emp_details) { if ($emp_details->exists) { $view = 'empdetail::emp_details.show'; } else { $view = 'empdetail::emp_details.new'; } return $this->response->title(trans('app.view') . ' ' . trans('empdetail::emp_details.name')) ->data(compact('emp_details')) ->view($view, true) ->output(); } /** * Show the form for creating a new emp_details. * * @param Request $request * * @return Response */ public function create(EmpDetailsRequest $request) { $emp_details = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('empdetail::emp_details.name')) ->view('empdetail::emp_details.create', true) ->data(compact('emp_details')) ->output(); } /** * Create new emp_details. * * @param Request $request * * @return Response */ public function store(EmpDetailsRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $emp_details = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('empdetail::emp_details.name')])) ->code(204) ->status('success') ->url(guard_url('empdetail/emp_details/' . $emp_details->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/empdetail/emp_details')) ->redirect(); } } /** * Show emp_details for editing. * * @param Request $request * @param Model $emp_details * * @return Response */ public function edit(EmpDetailsRequest $request, EmpDetails $emp_details) { return $this->response->title(trans('app.edit') . ' ' . trans('empdetail::emp_details.name')) ->view('empdetail::emp_details.edit', true) ->data(compact('emp_details')) ->output(); } /** * Update the emp_details. * * @param Request $request * @param Model $emp_details * * @return Response */ public function update(EmpDetailsRequest $request, EmpDetails $emp_details) { try { $attributes = $request->all(); $emp_details->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('empdetail::emp_details.name')])) ->code(204) ->status('success') ->url(guard_url('empdetail/emp_details/' . $emp_details->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('empdetail/emp_details/' . $emp_details->getRouteKey())) ->redirect(); } } /** * Remove the emp_details. * * @param Model $emp_details * * @return Response */ public function destroy(EmpDetailsRequest $request, EmpDetails $emp_details) { try { $emp_details->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('empdetail::emp_details.name')])) ->code(202) ->status('success') ->url(guard_url('empdetail/emp_details/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('empdetail/emp_details/' . $emp_details->getRouteKey())) ->redirect(); } } /** * Remove multiple emp_details. * * @param Model $emp_details * * @return Response */ public function delete(EmpDetailsRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('empdetail::emp_details.name')])) ->status("success") ->code(202) ->url(guard_url('empdetail/emp_details')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/empdetail/emp_details')) ->redirect(); } } /** * Restore deleted emp_details. * * @param Model $emp_details * * @return Response */ public function restore(EmpDetailsRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('empdetail::emp_details.name')])) ->status("success") ->code(202) ->url(guard_url('/empdetail/emp_details')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/empdetail/emp_details/')) ->redirect(); } } }