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