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