| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "Usuario".
- *
- * @property int $id
- * @property string|null $uid
- * @property string $email
- * @property string $nombre
- * @property string|null $telefono
- * @property string|null $facebook
- * @property bool|null $facebookVerificado
- * @property string|null $instagram
- * @property bool|null $instagramVerificado
- * @property string|null $twitter
- * @property bool|null $twitterVerificado
- * @property string|null $genero H: Hombre - M: Mujer
- * @property string|null $verificado
- * @property bool|null $liderGlobal
- * @property string|null $creado
- * @property string|null $modificado
- * @property string|null $eliminado
- *
- * @property Dependencia[] $dependencias
- * @property Grupo[] $grupos
- * @property UsuarioDependencia[] $usuariosDependencias
- * @property UsuarioGrupo[] $usuarioGrupos
- */
- class Usuario extends \yii\db\ActiveRecord {
- /**
- * {@inheritdoc}
- */
- public static function tableName() {
- return 'Usuario';
- }
- /**
- * {@inheritdoc}
- */
- public function rules() {
- return [
- [['nombre'], 'required'],
- [['facebookVerificado', 'instagramVerificado', 'twitterVerificado', 'liderGlobal'], 'boolean'],
- [['verificado', 'creado', 'modificado', 'eliminado'], 'safe'],
- [['uid', 'genero'], 'string', 'max' => 50],
- [['email', 'nombre', 'facebook', 'instagram', 'twitter'], 'string', 'max' => 100],
- [['telefono'], 'string', 'max' => 10],
- [['uid'], 'unique'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels() {
- return [
- 'id' => 'ID',
- 'uid' => 'Uid',
- 'email' => 'Email',
- 'nombre' => 'Nombre',
- 'telefono' => 'Teléfono',
- 'facebook' => 'Facebook',
- 'facebookVerificado' => 'Facebook Verificado',
- 'instagram' => 'Instagram',
- 'instagramVerificado' => 'Instagram Verificado',
- 'twitter' => 'Twitter',
- 'twitterVerificado' => 'Twitter Verificado',
- 'genero' => 'Género',
- 'verificado' => 'Verificado',
- 'liderGlobal' => 'Lider Global',
- 'creado' => 'Creado',
- 'modificado' => 'Modificado',
- 'eliminado' => 'Eliminado',
- ];
- }
- /**
- * Gets query for [[dependencias]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getDependencias() {
- return $this->hasMany(Dependencia::className(), ['id' => 'idDependencia'])->viaTable('UsuarioDependencia', ['idUsuario' => 'id']);
- }
- /**
- * Gets query for [[grupos]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getGrupos() {
- return $this->hasMany(Grupo::className(), ['id' => 'idGrupo'])->viaTable('UsuarioGrupo', ['idUsuario' => 'id']);
- }
- /**
- * Gets query for [[usuariosDependencias]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getUsuariosDependencias() {
- return $this->hasMany(UsuarioDependencia::className(), ['idUsuario' => 'id']);
- }
- /**
- * Gets query for [[usuariosGrupos]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getUsuariosGrupos() {
- return $this->hasMany(UsuarioGrupo::className(), ['idUsuario' => 'id']);
- }
- public function agregarClave($pwd) {
- $this->clave = Yii::$app->getSecurity()->generatePasswordHash($pwd);
- }
- public function validarClave($pwd) {
- return Yii::$app->getSecurity()->validatePassword($pwd, $this->clave);
- }
- }
|