| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "Usuario".
- *
- * @property int $id
- * @property string|null $uid
- * @property string $correo
- * @property string $nombre
- * @property int|null $idRol
- * @property string|null $genero
- * @property string|null $facebook
- * @property bool|null $facebookVerificado
- * @property string|null $twitter
- * @property bool|null $twitterVerificado
- * @property string|null $instagram
- * @property bool|null $instagramVerificado
- * @property string|null $creado
- * @property string|null $modificado
- * @property string|null $eliminado
- *
- * @property Rol $rol
- */
- class Usuario extends \yii\db\ActiveRecord {
- public const ACTIVO = 1;
- public const INACTIVO = 0;
- /**
- * {@inheritdoc}
- */
- public static function tableName() {
- return 'Usuario';
- }
- /**
- * {@inheritdoc}
- */
- public function rules() {
- return [
- [['correo', 'nombre'], 'required'],
- [['idRol'], 'default', 'value' => null],
- [['idRol'], 'integer'],
- [['facebookVerificado', 'twitterVerificado', 'instagramVerificado'], 'boolean'],
- [['creado', 'modificado', 'eliminado'], 'safe'],
- [['uid'], 'string', 'max' => 50],
- [['correo', 'nombre', 'genero', 'facebook', 'twitter', 'instagram'], 'string', 'max' => 100],
- [['uid'], 'unique'],
- [['idRol'], 'exist', 'skipOnError' => true, 'targetClass' => Rol::className(), 'targetAttribute' => ['idRol' => 'id']],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels() {
- return [
- 'id' => 'ID',
- 'uid' => 'Uid',
- 'correo' => 'Correo',
- 'nombre' => 'Nombre',
- 'idRol' => 'Id Rol',
- 'genero' => 'Genero',
- 'facebook' => 'Facebook',
- 'facebookVerificado' => 'Facebook Verificado',
- 'twitter' => 'Twitter',
- 'twitterVerificado' => 'Twitter Verificado',
- 'instagram' => 'Instagram',
- 'instagramVerificado' => 'Instagram Verificado',
- 'creado' => 'Creado',
- 'modificado' => 'Modificado',
- 'eliminado' => 'Eliminado',
- ];
- }
- public function agregarClave($pwd) {
- $this->clave = Yii::$app->getSecurity()->generatePasswordHash($pwd);
- }
- public function validarClave($pwd) {
- return Yii::$app->getSecurity()->validatePassword($pwd, $this->clave);
- }
- /**
- * Gets query for [[rol]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function geRol() {
- return $this->hasOne(Rol::className(), ['id' => 'idRol']);
- }
- }
|