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