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