| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * 描述.
- *
- * @author nj
- * @date 2021-05-18 20:46:19
- */
- namespace App\Models\Mysql;
- class ManagerModel extends BaseMysql
- {
- protected $table = 'manager';
- /**
- * UUID 键名
- * @var string
- */
- protected $uuidKeyName = 'manager_uid';
- /**
- * 隐藏字段.
- *
- * @var array
- */
- protected $hidden = ['password', 'salt', 'otp_secret'];
- /**
- * The "booted" method of the model.
- *
- * @return void
- */
- protected static function boot()
- {
- parent::boot();
- self::creating(function ($model) {
- $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
- });
- self::created(function ($model) {
- $uuid = hashEncodeId($model->id);
- $model->{$model->uuidKeyName} = $uuid;
- $model->save();
- });
- }
- /**
- * 关联角色.
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function role()
- {
- return $this->hasOne(PermissionRoleModel::class, 'id', 'role_id');
- }
- }
|