2023-09-18 09:11:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\common\model\user;
|
|
|
|
|
|
|
|
use app\common\model\BaseModel;
|
2023-09-19 15:39:19 +08:00
|
|
|
use think\facade\Db;
|
2023-09-18 09:11:13 +08:00
|
|
|
|
|
|
|
class User extends BaseModel
|
|
|
|
{
|
|
|
|
protected $name = 'user';
|
|
|
|
|
|
|
|
// 获取用户状态
|
2023-09-19 15:39:19 +08:00
|
|
|
public function getStatusTextAttr($value,$data): string
|
2023-09-18 09:11:13 +08:00
|
|
|
{
|
2023-09-19 15:39:19 +08:00
|
|
|
$status = [0=>'正常',1=>'冻结',2=>'删除'];
|
|
|
|
return $status[$data['status']];
|
2023-09-18 09:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 获取用户性别
|
2023-09-19 15:39:19 +08:00
|
|
|
public function getGenderTextAttr($value,$data): string
|
2023-09-18 09:11:13 +08:00
|
|
|
{
|
2023-09-19 15:39:19 +08:00
|
|
|
$gender = [0=>'男',1=>'女',2=>'未知'];
|
|
|
|
return $gender[$data['gender']];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getProvinceTextAttr($value,$data): string {
|
|
|
|
$data = Db::name('geo_province')->where('province_code',$data['province'])->findOrEmpty();
|
|
|
|
if(empty($data)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $data['province_name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCityTextAttr($value,$data): string {
|
|
|
|
$data = Db::name('geo_city')->where('city_code',$data['city'])->findOrEmpty();
|
|
|
|
if(empty($data)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $data['city_name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAreaTextAttr($value,$data): string {
|
|
|
|
$data = Db::name('geo_area')->where('area_code',$data['area'])->findOrEmpty();
|
|
|
|
if(empty($data)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $data['area_name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStreetTextAttr($value,$data): string {
|
|
|
|
$data = Db::name('geo_street')->where('street_code',$data['street'])->findOrEmpty();
|
|
|
|
if(empty($data)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $data['street_name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVillageTextAttr($value,$data): string {
|
|
|
|
$data = Db::name('geo_village')->where('village_code',$data['village'])->findOrEmpty();
|
|
|
|
if(empty($data)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $data['village_name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBrigadeTextAttr($value,$data): string {
|
|
|
|
$data = Db::name('geo_brigade')->where('id',$data['brigade'])->findOrEmpty();
|
|
|
|
if(empty($data)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $data['brigade_name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastLoginTimeAttr($value): string
|
|
|
|
{
|
|
|
|
return date('Y-m-d H:i:s',$value);
|
2023-09-18 09:11:13 +08:00
|
|
|
}
|
|
|
|
}
|