芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/models/Customer.php
<?php namespace app\models; use Yii; /** * This is the model class for table "{{%customer}}". * * @property int $id * @property string|null $name * @property string|null $email * @property string|null $mobile * @property int|null $sort_order * @property string|null $created * @property string|null $updated * @property int|null $trash * @property int|null $active * * @property License[] $licenses */ class Customer extends \yii\db\ActiveRecord { /** * {@inheritdoc} */ public static function tableName() { return '{{%customer}}'; } public function extraFields() { return ['customerlicenses']; } /** * {@inheritdoc} */ public function rules() { return [ [['name','username'],'required'], [['sort_order', 'trash', 'active'], 'integer'], [['created', 'updated'], 'safe'], [['name', 'mobile'], 'string', 'max' => 200], [['password'], 'string', 'max' => 150], [['username'], 'string', 'max' => 25], [['username','email','mobile'],'unique'], [['email'], 'string', 'max' => 255], ]; } public function beforeSave($insert) { if(parent::beforeSave($insert)){ if($this->isNewRecord || (!$this->isNewRecord && !empty($this->password))){ $this->password=password_hash($this->password,PASSWORD_DEFAULT); } return true; } return false; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => 'Nombre', 'email' => 'Correo', 'mobile' => 'Whatsapp', 'username' => 'Usuario', 'password'=>'Contraseña', 'sort_order' => 'Sort Order', 'created' => 'Created', 'updated' => 'Updated', 'trash' => 'Trash', 'active' => 'Active', ]; } /** * Gets query for [[Licenses]]. * * @return \yii\db\ActiveQuery */ public function getCustomerlicenses() { return $this->hasMany(CustomerLicense::class, ['customer_id' => 'id']); } }