/** * Stores the share. * * @param \Herbert\Framework\Http $http * * @return \Herbert\Framework\RedirectResponse */ public function store(Http $http) { $input = ['title' => $http->get('title'), 'slug' => $http->get('slug'), 'url' => $http->get('url')]; $rules = $this->repository->rules(); $validator = new Validator($input, $rules); $validator->validate($redirect = panel_url('Socializr::shares')); if ($this->repository->create($input)) { Notifier::success('Your <strong>sharing link</strong> has been created', true); return new RedirectResponse(panel_url('Socializr::index')); } }
/** * Updates a share. * * @param \Herbert\Framework\Http $http * * @return \Herbert\Framework\RedirectResponse */ public function update(Http $http) { $share = $this->getShare($http->get('set')); $input = ['title' => $http->get('title'), 'slug' => $http->get('slug'), 'url' => $http->get('url')]; $rules = $this->repository->rules(); $validator = new Validator($input, $rules); $validator->validate($redirect = panel_url('Socializr::shares')); if ($this->repository->modify($share->id, $input)) { Notifier::success('Your <strong>sharing link</strong> has been updated', true); return new RedirectResponse(panel_url('Socializr::index')); } return redirect_response(panel_url('Socializr::shares', ['action' => 'edit', 'share' => $share->id])); }
/** * Updates a set. * * @param \Herbert\Framework\Http $http * * @return \Herbert\Framework\RedirectResponse */ public function update(Http $http) { $set = $this->getSet($http->get('set')); $input = ['title' => $http->get('title'), 'type' => $http->get('type'), 'slug' => $http->get('slug')]; if ($http->get('type') === 'SHARE') { $input['shares'] = $http->get('shares'); } else { $input['profile'] = $http->get('profile'); } $rules = $this->repository->rules($http->get('type')); $validator = new Validator($input, $rules); $validator->validate($redirect = panel_url('Socializr::sets', ['data' => $input, 'action' => 'edit', 'set' => $set->id])); $input['slug'] = $this->repository->modify($set->id, $input); return redirect_response(panel_url('Socializr::sets', ['action' => 'edit', 'set' => $set->id])); }
/** * Stores the set. * * @param \Herbert\Framework\Http $http * * @return \Herbert\Framework\RedirectResponse */ public function store(Http $http) { /* * 1. Collect all http data * 2. Validate * 3. Pass off to Repo */ $input = ['title' => $http->get('title'), 'type' => $http->get('type'), 'slug' => $http->get('slug')]; if ($http->get('type') === 'SHARE') { $input['shares'] = $http->get('shares'); } else { $input['profile'] = $http->get('profile'); } $rules = $this->repository->rules($input['type']); $validator = new Validator($input, $rules); $validator->validate($redirect = panel_url('Socializr::sets')); if ($this->repository->create($input)) { Notifier::success('Your Set has been created', true); return new RedirectResponse(panel_url('Socializr::index')); } Notifier::error('Something went wrong there, please try again', true); return (new RedirectResponse(panel_url('Socializr::sets')))->with('__form_data', $input); }