/** * Processes the form. * * @param string $mode * @param int $id * @return \Illuminate\Http\RedirectResponse */ protected function processForm($mode, $id = null) { $input = array_filter(Input::all()); //$input['slug'] = isset($input['name']) ? snake_case($input['name']) : ''; $rules = ['name' => 'required', 'description' => 'required', 'value' => 'required', 'status' => 'boolean']; if ($id) { $setting = $this->settings->find($id); $messages = $this->validateSetting($input, $rules); if ($messages->isEmpty()) { $setting->update($input); } } else { $messages = $this->validateSetting($input, $rules); if ($messages->isEmpty()) { $setting = $this->settings->create($input); } } if ($messages->isEmpty()) { return Redirect::to(route('admin.settings.index'))->with('success', 'Setting Updated!'); } return Redirect::back()->withInput()->withErrors($messages); }
/** * Processes the form. * * @param string $mode * @param int $id * @return \Illuminate\Http\RedirectResponse */ protected function processForm($mode, $id = null) { $input = array_filter(Input::all()); $rules = ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|unique:users']; if ($id) { $user = $this->users->createModel()->find($id); $rules['email'] .= ",email,{$user->email},email"; $messages = $this->validateUser($input, $rules); if ($messages->isEmpty()) { $this->users->update($user, $input); } } else { $messages = $this->validateUser($input, $rules); if ($messages->isEmpty()) { $user = $this->users->create($input); $code = Activation::create($user); Activation::complete($user, $code); } } if ($messages->isEmpty()) { return Redirect::to('users'); } return Redirect::back()->withInput()->withErrors($messages); }