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