// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\common\model; use cores\BaseModel; use think\model\relation\HasOne; use think\model\relation\HasMany; use think\model\relation\BelongsTo; /** * 公司用户池模型类 * Class User * @package app\common\model */ class Account extends BaseModel { // 定义表名 protected $name = 'account'; // 定义主键 protected $pk = 'account_id'; /** * 公司表 * @return \think\model\relation\BelongsTo */ public function company(): BelongsTo { $module = self::getCalledModule(); return $this->belongsTo("app\\{$module}\\model\\Company"); } /** * 获取用户信息 * @param $where * @param array $with * @return static|array|false|null */ public static function detail($where, array $with = []) { $filter = ['is_delete' => 0]; if (is_array($where)) { $filter = array_merge($filter, $where); } else { $filter['account_id'] = (int)$where; } return static::get($filter, $with); } /** * 指定的手机号是否已存在 * @param string $mobile * @return bool */ public static function checkExistByMobile(string $mobile): bool { $model = new static; return (bool)$model->where('mobile', '=', $mobile) ->where('is_delete', '=', 0) ->value($model->getPk()); } }