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