| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "Usuario".
- *
- * @property int $id
- * @property string $rfc
- * @property string $correo
- * @property string $clave
- * @property string $nombre
- * @property string $apellidoPaterno
- * @property int|null $estatus 0:inactivo, 1:activo
- */
- 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 [
- [['rfc', 'correo', 'clave', 'nombre', 'apellidoPaterno'], 'required'],
- [['estatus'], 'default', 'value' => null],
- [['estatus'], 'integer'],
- [['rfc'], 'string', 'max' => 13],
- [['correo', 'clave', 'nombre', 'apellidoPaterno'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels() {
- return [
- 'id' => 'ID',
- 'rfc' => 'Rfc',
- 'correo' => 'Correo',
- 'clave' => 'Clave',
- 'nombre' => 'Nombre',
- 'apellidoPaterno' => 'Apellido Paterno',
- 'apellidoMaterno' => 'Apellido Materno',
- 'estatus' => 'Estatus',
- ];
- }
- public function agregarClave($pwd) {
- $this->clave = Yii::$app->getSecurity()->generatePasswordHash($pwd);
- }
- public function validarClave($pwd) {
- return Yii::$app->getSecurity()->validatePassword($pwd, $this->clave);
- }
- }
|