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