1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "Usuario".
- *
- * @property string $id
- * @property string $correo
- * @property string $clave
- * @property string $nombre
- * @property int|null $estatus 0:inactivo, 1:activo
- * @property string $telefono
- * @property string|null $alias
- * @property string|null $foto
- * @property string $rol
- * @property string|null $creado
- * @property string|null $modificado
- * @property string|null $eliminado
- *
- * @property Media[] $media
- */
- class Usuario extends ModeloBase {
- public const ACTIVO = 1;
- public const INACTIVO = 0;
- /**
- * {@inheritdoc}
- */
- public static function tableName() {
- return 'Usuario';
- }
- /**
- * {@inheritdoc}
- */
- public function rules() {
- return [
- [['id', 'correo', 'clave', 'nombre', 'telefono', 'rol'], 'required'],
- [['estatus'], 'default', 'value' => null],
- [['estatus'], 'integer'],
- [['creado', 'modificado', 'eliminado'], 'safe'],
- [['id'], 'string', 'max' => 36],
- [['correo', 'clave', 'nombre', 'telefono', 'alias', 'rol'], 'string', 'max' => 100],
- [['foto'], 'string', 'max' => 300],
- [['id'], 'unique'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels() {
- return [
- 'id' => 'ID',
- 'correo' => 'Correo',
- 'clave' => 'Clave',
- 'nombre' => 'Nombre',
- 'estatus' => 'Estatus',
- 'telefono' => 'Telefono',
- 'alias' => 'Alias',
- 'foto' => 'Foto',
- 'rol' => 'Rol',
- 'creado' => 'Creado',
- 'modificado' => 'Modificado',
- 'eliminado' => 'Eliminado',
- ];
- }
- /**
- * Gets query for [[media]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getMedia() {
- return $this->hasMany(Media::class, ['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);
- }
- }
|