WokerTask/app/common/model/Company.php

83 lines
2.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model;
use app\common\model\contract\Contract;
use app\common\model\dict\DictData;
use think\facade\Db;
use think\model\concern\SoftDelete;
/**
* Company模型
* Class Company
* @package app\common\model
*/
class Company extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $name = 'company';
public function getCompanyTypeNameAttr($value)
{
return DictData::where('id', $value)->value('name');
}
public function getProvinceNameAttr($value)
{
return Db::name('geo_province')->where(['province_code' => $this->province])->value('province_name');
}
public function getCityNameAttr($value)
{
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
}
public function getAreaNameAttr($value)
{
return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name');
}
public function getStreetNameAttr($value)
{
return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name');
}
public function getVillageNameAttr($value)
{
return Db::name('geo_village')->where(['village_code' => $this->village])->value('village_name');
}
public function getBrigadeNameAttr($value)
{
return Db::name('geo_brigade')->where(['id' => $this->brigade])->value('brigade_name');
}
public function getAreaManagerNameAttr($value)
{
return Db::name('admin')->where(['id' => $this->area_manager])->value('name');
}
public function getContractAttr()
{
$find=Contract::where('party_a|party_b', $this->id)->field('check_status,status')->find();
if($find){
return $find->toArray();
}else{
return [];
}
}
}