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