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