form = AccountForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('litecms.contact.modules'), 'contact', guard_url('contact')); } /** * Display a list of account. * * @return Response */ public function index(AccountResourceRequest $request) { $request = $request->all(); $page = AccountActions::run('paginate', $request); $data = new AccountsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('contact::account.names')) ->view('contact::account.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display account. * * @param Request $request * @param Model $account * * @return Response */ public function show(AccountResourceRequest $request, Account $model) { $form = $this->form; $modules = $this->modules; $data = new AccountResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('contact::account.name')) ->data(compact('data', 'form', 'modules')) ->view('contact::account.show') ->output(); } /** * Show the form for creating a new account. * * @param Request $request * * @return Response */ public function create(AccountResourceRequest $request, Account $model) { $form = $this->form; $modules = $this->modules; $data = new AccountResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('contact::account.name')) ->view('contact::account.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new account. * * @param Request $request * * @return Response */ public function store(AccountResourceRequest $request, Account $model) { try { $request = $request->all(); $model = AccountAction::run('store', $model, $request); $data = new AccountResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('contact::account.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('contact/account/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/contact/account')) ->redirect(); } } /** * Show account for editing. * * @param Request $request * @param Model $account * * @return Response */ public function edit(AccountResourceRequest $request, Account $model) { $form = $this->form; $modules = $this->modules; $data = new AccountResource($model); // return view('contact::account.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('contact::account.name')) ->view('contact::account.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the account. * * @param Request $request * @param Model $account * * @return Response */ public function update(AccountResourceRequest $request, Account $model) { try { $request = $request->all(); $model = AccountAction::run('update', $model, $request); $data = new AccountResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('contact::account.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('contact/account/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('contact/account/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the account. * * @param Model $account * * @return Response */ public function destroy(AccountResourceRequest $request, Account $model) { try { $request = $request->all(); $model = AccountAction::run('destroy', $model, $request); $data = new AccountResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('contact::account.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('contact/account/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('contact/account/' . $model->getRouteKey())) ->redirect(); } } }