Ejemplo n.º 1
0
 public function adminAjustes()
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('tos', new Validate\Rule\MinLength(8))->addRule('tos', new Validate\Rule\MaxLength(8192))->addFilter('tos', FilterFactory::escapeHTML());
     $req = $this->request;
     if (!$vdt->validate($req->post())) {
         throw new TurnbackException($vdt->getErrors());
     }
     $ajustes = Ajuste::all();
     foreach ($ajustes as $ajuste) {
         $newValue = $vdt->getData($ajuste->key);
         if (isset($newValue)) {
             $ajuste->value = $newValue;
             $ajuste->save();
             AdminlogCtrl::createLog('', 1, 'mod', $this->session->user('id'), $ajuste);
         }
     }
     $this->flash('success', 'Los ajustes se han modificado exitosamente.');
     $this->redirectTo('shwAdmAjuste');
 }
Ejemplo n.º 2
0
     $table->integer('votos')->default(0);
     $table->integer('autor_id')->unsigned();
     $table->foreign('autor_id')->references('id')->on('usuarios')->onDelete('cascade');
     $table->timestamps();
     $table->softDeletes();
 });
 Capsule::schema()->create('comentario_votos', function ($table) {
     $table->engine = 'InnoDB';
     $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)));
Ejemplo n.º 3
0
 public function verTos()
 {
     $tos = Ajuste::where('key', 'tos')->firstOrFail();
     $this->render('portal/tos.twig', ['tos' => $tos->toArray()]);
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAjustes()
 {
     return $this->hasMany(Ajuste::className(), ['id_tipo_modificacion' => 'id_tipo_ajuste']);
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAjustes0()
 {
     return $this->hasMany(Ajuste::className(), ['id_usuario_reversa' => 'idusuario']);
 }
Ejemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdAjuste()
 {
     return $this->hasOne(Ajuste::className(), ['id_ajuste' => 'id_ajuste']);
 }