/** * Cria um novo tipo de Usuário * @param string $user_type_descr Descrição completa do tipo de usuário * @param string $user_type_abrev abreviação do tipo de usuário * @return bollean true caso sucesso, false caso ocorra algum erro */ public function createUserType($user_type_descr, $user_type_abrev) { $user_type = new UserType(); $user_type->user_type_descr = $user_type_descr; $user_type->user_type_abrev = $user_type_abrev; return $user_type->save(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new UserType(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['UserType'])) { $model->attributes = $_POST['UserType']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Create new usertype * * @return Response */ public function saveUserType(Request $request) { //Validate the Request $this->validate($request, ['name' => 'required|unique:user_types|max:255']); $ut = new UserType(); $ut->name = $request->name; $ut->save(); \Session::flash('flash_message', $request->name . ' has been created!'); \Session::flash('flash_message_level', 'success'); return Redirect::to('admin/usertype'); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUserType !== null) { if ($this->aUserType->isModified() || $this->aUserType->isNew()) { $affectedRows += $this->aUserType->save($con); } $this->setUserType($this->aUserType); } if ($this->asfGuardUser !== null) { if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) { $affectedRows += $this->asfGuardUser->save($con); } $this->setsfGuardUser($this->asfGuardUser); } if ($this->isNew()) { $this->modifiedColumns[] = sfGuardUserProfilePeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = sfGuardUserProfilePeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += sfGuardUserProfilePeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collJobNotess !== null) { foreach ($this->collJobNotess as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collJobAttachments !== null) { foreach ($this->collJobAttachments as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collPhotographers !== null) { foreach ($this->collPhotographers as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collClients !== null) { foreach ($this->collClients as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collLogs !== null) { foreach ($this->collLogs as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }