public function save(Http $http) { $inputs = $http->only($this->options); if (!$this->validate($inputs) || !$this->check($inputs)) { return redirect_response(panel_url('GitContent::settings'))->with('__form_data', $inputs); } update_option($this->optionName, $inputs); Notifier::success('Settings have been saved', true); return redirect_response(panel_url('GitContent::settings')); }
/** * Delete an IP address. * * @param Http $http * * @return \Herbert\Framework\Response * * @throws HttpErrorException */ public function delete(Http $http) { try { $address = Access::findOrFail($http->get('id')); } catch (ModelNotFoundException $e) { throw new HttpErrorException(404, "It looks like that address doesn't exist."); } $address->delete(); return redirect_response(panel_url('ApiPosts::mainPanel')); }
/** * 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')); } }
/** * 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); }
/** * Destroys a share. * * @param \Herbert\Framework\Http $http * * @return \Herbert\Framework\RedirectResponse */ public function postDestroy(Http $http) { $share = $this->getShare($http->get('set')); $share->delete(); return redirect_response(panel_url('Socializr::index')); }
namespace Socializr; /** @var \Herbert\Framework\API $api */ use Socializr\Services\Extrapolator; /** * Allows the use of {{ Socializr.helper() }} to use any public method from the Helper Class */ $api->add('helper', function () { $args = func_get_args(); $method = array_shift($args); return forward_static_call_array(__NAMESPACE__ . '\\Helper::' . $method, $args); }); /** * Allows usage of {{ Socializr.edit() }} to return the edit link for a set or share */ $api->add('edit', function ($type, $id) { return panel_url('Socializr::' . $type, ['action' => 'edit', 'set' => $id]); }); /** * returns panel url */ $api->add('panel', function ($type) { return panel_url('Socializr::' . $type); }); /** * returns extrapolated data. (used for shortcode) */ $api->add('showSet', function ($slug) { $extrapolator = new Extrapolator($slug, true); return $extrapolator->fetch(); });