feat : user
This commit is contained in:
@@ -21,7 +21,8 @@ use Hyperf\DbConnection\Model\Model;
|
||||
* @property string $token
|
||||
* @property string $last_ip
|
||||
* @property string $reg_ip
|
||||
* @property string $last_time
|
||||
* @property string $last_time
|
||||
* @property string $invite_code
|
||||
* @property string $create_time
|
||||
* @property string $update_time
|
||||
* @property int $is_del
|
||||
@@ -56,4 +57,37 @@ class User extends Model
|
||||
{
|
||||
return $this->where('id', $id)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @return array
|
||||
*/
|
||||
public function getInfoByIds(array $ids): array
|
||||
{
|
||||
$data = $this->whereIn('id', $ids)->get();
|
||||
|
||||
if ($data->isEmpty()) return [];
|
||||
|
||||
$data = $data->toArray();
|
||||
|
||||
return array_column($data,null,'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return int
|
||||
*/
|
||||
public function checkInviteCodeIsUse(string $code): int
|
||||
{
|
||||
return $this->where('invite_code', $code)->count() ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return int
|
||||
*/
|
||||
public function getUserIdByInviteCode(string $code): int
|
||||
{
|
||||
return $this->where('invite_code', $code)->value('id') ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user