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