form = NationalityForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('litecms.aml.modules'), 'aml', guard_url('aml')); } /** * Display a list of nationality. * * @return Response */ public function index(NationalityResourceRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $page = Nationality::pushScope(new RequestScope()) ->pushScope(new NationalityResourceScope()) ->paginate($pageLimit); $data = new NationalitiesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('aml::nationality.names')) ->view('aml::nationality.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display nationality. * * @param Request $request * @param Model $nationality * * @return Response */ public function show(NationalityResourceRequest $request, Nationality $model) { $form = $this->form; $modules = $this->modules; $data = new NationalityResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('aml::nationality.name')) ->data(compact('data', 'form', 'modules')) ->view('aml::nationality.show') ->output(); } /** * Show the form for creating a new nationality. * * @param Request $request * * @return Response */ public function create(NationalityResourceRequest $request, Nationality $model) { $form = $this->form; $modules = $this->modules; $data = new NationalityResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('aml::nationality.name')) ->view('aml::nationality.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new nationality. * * @param Request $request * * @return Response */ public function store(NationalityResourceRequest $request, Nationality $model) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $model = $model->create($attributes); $data = new NationalityResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('aml::nationality.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('aml/nationality/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/aml/nationality')) ->redirect(); } } /** * Show nationality for editing. * * @param Request $request * @param Model $nationality * * @return Response */ public function edit(NationalityResourceRequest $request, Nationality $model) { $form = $this->form; $modules = $this->modules; $data = new NationalityResource($model); // return view('aml::nationality.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('aml::nationality.name')) ->view('aml::nationality.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the nationality. * * @param Request $request * @param Model $nationality * * @return Response */ public function update(NationalityResourceRequest $request, Nationality $model) { try { $attributes = $request->all(); $model->update($attributes); $data = new NationalityResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('aml::nationality.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('aml/nationality/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('aml/nationality/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the nationality. * * @param Model $nationality * * @return Response */ public function destroy(NationalityResourceRequest $request, Nationality $model) { try { $model->delete(); $data = new NationalityResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('aml::nationality.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('aml/nationality/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('aml/nationality/' . $model->getRouteKey())) ->redirect(); } } }