repository = $nationality; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Aml\Repositories\Criteria\NationalityResourceCriteria::class); } /** * Display a list of nationality. * * @return Response */ public function index(NationalityRequest $request) { return $this->repository ->setPresenter(\Bixo\Aml\Repositories\Presenter\NationalityPresenter::class) ->paginate(); } /** * Display nationality. * * @param Request $request * @param Model $nationality * * @return Response */ public function show(NationalityRequest $request, Nationality $nationality) { return $nationality->setPresenter(\Bixo\Aml\Repositories\Presenter\NationalityListPresenter::class); ; } /** * Create new nationality. * * @param Request $request * * @return Response */ public function store(NationalityRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('aml::nationality.name')]); $code = 204; $status = 'success'; $url = guard_url('aml/nationality/' . $nationality->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('aml/nationality'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the nationality. * * @param Request $request * @param Model $nationality * * @return Response */ public function update(NationalityRequest $request, Nationality $nationality) { try { $data = $request->all(); $nationality->update($data); $message = trans('messages.success.updated', ['Module' => trans('aml::nationality.name')]); $code = 204; $status = 'success'; $url = guard_url('aml/nationality/' . $nationality->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('aml/nationality/' . $nationality->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the nationality. * * @param Model $nationality * * @return Response */ public function destroy(NationalityRequest $request, Nationality $nationality) { try { $nationality->delete(); $message = trans('messages.success.deleted', ['Module' => trans('aml::nationality.name')]); $code = 202; $status = 'success'; $url = guard_url('aml/nationality/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('aml/nationality/' . $nationality->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }