/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $categoria = new Categoria($request->all()); $this->validate($request, ['nombre' => 'required|min:2|max:50|unique:categorias']); $categoria->save(); Flash::success('Categoria ' . $categoria->name . ' registrada exitosamente!!'); return redirect()->route('admin.categorias.index'); }
public function nueva() { View::select(null, "json"); $nueva = new Categoria(Input::post("categoria")); if ($nueva->save()) { $buscar = new Categoria(); $options = $buscar->getInOptionsFormat(); $this->data = array("valid" => true, "mensaje" => "Categoria Agregada con éxito", "html" => $options); } else { $this->data = array("valid" => false, "mensaje" => strip_tags(str_replace("<br>", "\n", ob_get_contents()))); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Categoria(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Categoria'])) { $model->attributes = $_POST['Categoria']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->Id)); } } $this->render('create', array('model' => $model)); }
public function agregarCategoria($nomCategoria) { $resultado = array('valor' => 1, 'message' => 'Su solicitud ha sido procesada correctamente.'); $categoria = new Categoria(); $categoria->nomCategoria = $nomCategoria; $sql = "select * from Categoria where nomCategoria='" . $nomCategoria . "'"; if (count(Yii::app()->db->createCommand($sql)->queryAll()) > 0) { $resultado = array('valor' => 0, 'message' => 'La Categoria ya Existe'); } if (count(Yii::app()->db->createCommand($sql)->queryAll()) < 1) { if (!$categoria->save()) { $resultado = array('valor' => 0, 'message' => 'No hemos podido realizar su solicitud, intentelo nuevamente'); } } return $resultado; }
$table->increments('id'); $table->integer('valor'); $table->integer('usuario_id')->unsigned(); $table->integer('comentario_id')->unsigned(); $table->foreign('comentario_id')->references('id')->on('comentarios')->onDelete('cascade'); $table->timestamps(); }); $ajuste = new Ajuste(); $ajuste->key = 'tos'; $ajuste->value_type = 'txt'; $ajuste->value = 'Términos y condiciones de uso.'; $ajuste->description = 'Términos y condiciones para el uso de la plataforma.'; $ajuste->save(); $categoria = new Categoria(); $categoria->nombre = 'General'; $categoria->save(); $usuario = new Usuario(); $usuario->email = $_POST['usr_email']; $usuario->password = password_hash($_POST['usr_password'], PASSWORD_DEFAULT); $usuario->nombre = $_POST['usr_nombre']; $usuario->apellido = $_POST['usr_apellido']; $usuario->img_tipo = 1; $usuario->img_hash = md5(strtolower(trim($usuario->email))); $patrulla = new Patrulla(); $patrulla->nombre = 'Aministrador'; $patrulla->descripcion = 'Admnistrador que instaló la plataforma.'; $patrulla->save(); $poderes = [['nombre' => 'Moderar', 'descripcion' => 'Moderar en la plataforma.'], ['nombre' => 'Configurar plataforma', 'descripcion' => 'Configurar parámetros de Virtugora.'], ['nombre' => 'Administrar organismos', 'descripcion' => 'Definir los organimos existentes.'], ['nombre' => 'Administrar funcionarios', 'descripcion' => 'Asignar los funcionarios a sus respectivos organismos.'], ['nombre' => 'Administrar patrullas', 'descripcion' => 'Definir los distintos grupos de moderación.'], ['nombre' => 'Administrar moderadores', 'descripcion' => 'Asignar los usuarios que serán moderadores.'], ['nombre' => 'Verificar ciudadanos', 'descripcion' => 'Registrar como verificados a usuarios que lo demuestren.']]; Poder::insert($poderes); $patrulla->poderes()->attach([1, 2, 3, 4, 5, 6, 7]); $usuario->patrulla()->associate($patrulla);
/** * Cria uma categoria Pai */ public function actionAddPai($nome = null) { if ($nome != null) { $categoria = new Categoria(); $categoria->nome = $nome; //Salva a nova categoria pai if ($categoria->save()) { echo CHtml::tag('option', array('value' => $categoria->cod_categoria), CHtml::encode($categoria->nome), true); } } }
/** * 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->aCategoria !== null) { if ($this->aCategoria->isModified() || $this->aCategoria->isNew()) { $affectedRows += $this->aCategoria->save($con); } $this->setCategoria($this->aCategoria); } if ($this->aEstadoPelicula !== null) { if ($this->aEstadoPelicula->isModified() || $this->aEstadoPelicula->isNew()) { $affectedRows += $this->aEstadoPelicula->save($con); } $this->setEstadoPelicula($this->aEstadoPelicula); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->comentariosScheduledForDeletion !== null) { if (!$this->comentariosScheduledForDeletion->isEmpty()) { ComentarioQuery::create()->filterByPrimaryKeys($this->comentariosScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->comentariosScheduledForDeletion = null; } } if ($this->collComentarios !== null) { foreach ($this->collComentarios as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->reservassScheduledForDeletion !== null) { if (!$this->reservassScheduledForDeletion->isEmpty()) { ReservasQuery::create()->filterByPrimaryKeys($this->reservassScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->reservassScheduledForDeletion = null; } } if ($this->collReservass !== null) { foreach ($this->collReservass as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->socioAlquilersScheduledForDeletion !== null) { if (!$this->socioAlquilersScheduledForDeletion->isEmpty()) { SocioAlquilerQuery::create()->filterByPrimaryKeys($this->socioAlquilersScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->socioAlquilersScheduledForDeletion = null; } } if ($this->collSocioAlquilers !== null) { foreach ($this->collSocioAlquilers as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
require_once "../class/operazione.php"; $objOperation = new Operazione(); $objOperation->save($_POST['date'], $_POST['importo'], $_POST['categoria'], $_POST['note']); header('Location: ../list.php'); } break; case "saveNewCateg" : { require_once "../class/operazione.php"; $objCategoria = new Categoria(); $objCategoria->save($_POST['descrizione']); header('Location: ../list.php'); } break; default : { echo "Errore: evento non gestito"; } } ?>
public function postCriarEmpreendimento() { // validate $rules = array('name' => 'required'); $validator = Validator::make(Input::all(), $rules); $file = Input::file('imagem'); // Pega o arquivo que vem do formulario $filename = $file->getClientOriginalName(); // Pega o nome do arquivo. // Função para Resize da imagem e salvar na pasta correta. Image::make($file->getRealPath())->resize(200, null, function ($constraint) { $constraint->aspectRatio(); })->save(public_path() . '/assets/empreendimentos/capas/' . $filename); // processe o inÃcio de uma sessão if ($validator->fails()) { return Redirect::to('admin/empreendimento')->withErrors($validator); } else { // Criar $empreendimento = new Categoria(); $empreendimento->name = Input::get('name'); $empreendimento->imagem = '/assets/empreendimentos/capas/' . $filename; $empreendimento->save(); $idCategoria = $empreendimento->id; // Grava as informações na tabela Obras com os valor 0, e grava com o $idCategoria. $dadosObras = array('obras.projetos' => 0, 'obras.servicos_inicias' => 0, 'obras.fundacoes' => 0, 'obras.estrutura' => 0, 'obras.alvenaria' => 0, 'obras.instalacoe_eletricas' => 0, 'obras.instalacoes_hidrossanitarias' => 0, 'obras.pavimentacao' => 0, 'obras.revestimentos' => 0, 'obras.cobertura_e_forros' => 0, 'obras.esquadrias' => 0, 'obras.pintura' => 0, 'obras.acabamento' => 0, 'obras.andamento_geral_da_obra' => 0, 'obras.categorias_id' => $idCategoria); Obra::create($dadosObras); // Grava as informações na tabela Dados com algum valor e com o $idCategoria $dadosDados = array('dados.descricao' => 'Seu Descrição aqui', 'dados.video' => 'Seu video aqui', 'dados.categorias_id' => $idCategoria); Dado::create($dadosDados); // Grava as informações na tabela Construindo com algum valor e com o $idCategoria $dadosConstruindo = array('construindo_com_qualidade.descricao' => 'Seu Descrição aqui', 'construindo_com_qualidade.categorias_id' => $idCategoria); Construindo::create($dadosConstruindo); // redirect Session::flash('message', 'Empreendimento criado com sucesso!'); return Redirect::to('admin/empreendimento/editar-dados-gerais/' . $idCategoria); } }