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