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