data_center/app/common/model/user/User.php

78 lines
2.1 KiB
PHP

<?php
namespace app\common\model\user;
use app\common\model\BaseModel;
use think\facade\Db;
class User extends BaseModel
{
protected $name = 'user';
// 获取用户状态
public function getStatusTextAttr($value,$data): string
{
$status = [0=>'正常',1=>'冻结',2=>'删除'];
return $status[$data['status']];
}
// 获取用户性别
public function getGenderTextAttr($value,$data): string
{
$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);
}
}