/** * Handle form request. * * @param \Symfony\Component\Form\FormInterface $form * @param \Symfony\Component\HttpFoundation\Request $request * * @return bool */ public function handle(FormInterface $form, Request $request) { $this->logger->info('UserEditFormHandler handle()'); if (!$request->isMethod('POST')) { return false; } $form->handleRequest($request); if (!$form->isValid()) { $this->flashManager->getErrorMessage(); return false; } $this->userManager->update($form->getData()); $this->flashManager->getSuccessMessage('update successfully!'); return true; }
/** * @param FormInterface $form * @param Request $request * * @return bool */ public function handle(FormInterface $form, Request $request) { $this->logger->info('TrainEditHandler handle()'); if (!$request->isMethod('POST')) { return false; } $form->handleRequest($request); if (!$form->isValid()) { $this->flashManager->getErrorMessage(); return false; } $validTrain = $form->getData(); $this->trainManager->update($validTrain); $this->flashManager->getSuccessMessage('Train was updated successfully!'); return true; }
private function update($tabla) { switch ($tabla) { case 'Service': $service = Service::update($service_id, array('driver_id' => $driver_id, 'status_id' => "2", 'car_id' => $driver_tmp->car_id)); $this->servicio = Service::find($this->servicio_id); $this->validar($service); break; case 'Driver': $driver = Driver::update($this->driver_id, array("available" => "0")); $this->conductor = Driver::find($this->conductor_id); $this->validar($driver); break; } }
public static function update($id) { $service = Service::find($id); if ($service) { $params = $_POST; $service = new Service(array('id' => $id, 'name' => $params['name'], 'reservation_unit' => $params['reservation_unit'], 'rate' => $params['rate'], 'opens_at' => $params['opens_at'], 'closes_at' => $params['closes_at'])); $errors = $service->errors(); if (count($errors) > 0) { View::make('service/edit.html', array('service' => $service, 'message' => 'Virheelliset tiedot!', 'error' => true, 'errors' => $errors)); } else { $service->update(); View::make('service/edit.html', array('service' => $service, 'message' => 'Muutokset tallennettu!')); } } else { Redirect::to(\Slim\Slim::getInstance()->urlFor('services_index'), array('message' => 'Palvelua ei löytynyt!', 'error' => true)); } }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { return $this->service->update($request->all(), $id); }
$_SESSION['msg'] = "A adição desse serviço falhou."; header('Location:../views/services.php'); } break; case 'update': if ($_POST['title'] != "" && $_POST['description'] != "") { if ($_FILES['image']['tmp_name'] != "") { if (is_uploaded_file($_FILES['image']['tmp_name'])) { $_POST['image'] = resizer($_FILES['image']); } } else { $_POST['image'] = Service::selectImage($_POST['id'], $connect); } $service = new Service($_POST); try { $service->update($_POST['id'], $connect); $_SESSION['msg'] = "Serviço editado com sucesso."; } catch (PDOException $e) { $_SESSION['msg'] = "A edição desse serviço falhou."; } header('Location:../views/services.php'); } break; case 'delete': if (isset($_POST['id'])) { if (Service::delete($_POST['id'], $connect)) { $_SESSION['msg'] = "Serviço deletado."; header('Location:../views/services.php'); } } else { $_SESSION['msg'] = "Houve falha ao excluir esse serviço.";
public function update() { ipRequest()->mustBePost(); $post = ipRequest()->getPost(); if (!isset($post['id']) || !isset($post['username']) || !isset($post['email'])) { throw new \Ip\Exception('Missing required parameters'); } $form = Helper::updateForm(); $form->removeSpamCheck(); $errors = $form->validate($post); $userId = $post['id']; $username = $post['username']; $email = $post['email']; if (isset($post['password'])) { $password = $post['password']; } else { $password = null; } $existingUser = Service::getByUsername($username); if ($existingUser && $existingUser['id'] != $userId) { $errors['username'] = __('Already taken', 'Ip-admin', false); } if ($errors) { $data = array('status' => 'error', 'errors' => $errors); return new \Ip\Response\Json($data); } Service::update($userId, $username, $email, $password); $data = array('status' => 'ok'); return new \Ip\Response\Json($data); }
public static function update($id) { $params = $_POST; $employees = Employee::all(); $attributes = array('id' => $id, 'name' => $params['name'], 'price' => $params['price'], 'description' => $params['description']); $service = new Service($attributes); $errors = $service->errors(); // $list = $_POST['checkbox']; foreach ($employees as $emp) { if (isset($_POST[$emp->id])) { OfferedServicesController::create($emp->id, $id); // $attr = array( // 'employeeid' => $emp->id, // 'serviceid' => $id // ); // $offer = new OfferedServices($attr); // $offer->save(); } else { OfferedServicesController::destroy($emp->id, $id); // $offer = new OfferedServices(array('employeeid' => $emp->id, 'serviceid' => $id)); // $offer->destroy($emp->id, $id); } } // // foreach ($list as $employee) { // $attr = array( // 'employeeid' => $employee, // 'serviceid' => $id // ); // // $offer = new OfferedServices($attr); // $offer->save(); // } $employeeList = OfferedServicesController::getEmployees($id, $employees); if (count($errors) > 0) { View::make('service/edit.html', array('errors' => $errors, 'attributes' => $attributes, 'employees' => $employees, 'employeeList' => $employeeList)); } else { $service->update(); Redirect::to('/palvelut/' . $service->id, array('message' => "Palveluun tehdyt muutokset tallennettu!")); } }