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