初始化项目
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user