middleware(function ($request, $next) { $this->form = AccountForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('bixo.account.modules'), 'account', guard_url('account')); return $next($request); }); } /** * 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('account::account.names')) ->view('account::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('account::account.name')) ->data(compact('data', 'form', 'modules')) ->view('account::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('account::account.name')) ->view('account::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('account::account.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('account/account/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/account/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('account::account.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('account::account.name')) ->view('account::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('account::account.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('account/account/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('account/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('account::account.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('account/account/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('account/account/' . $model->getRouteKey())) ->redirect(); } } }