quanwei
2025-10-29 76ed09d116f484b261d44219de300b79eb2013b3
admin/app/common/model/plus/business/Business.php
@@ -2,6 +2,7 @@
namespace app\common\model\plus\business;
use app\common\model\BaseModel;
use app\common\model\settings\Region;
/**
 * 名片管理模型
@@ -9,7 +10,26 @@
class Business extends BaseModel
{
    protected $name='business_card';
    /**
     * 追加字段
     * @var string[]
     */
    protected $append = ['region'];
    /**
     * 地区名称
     * @param $value
     * @param $data
     * @return array
     */
    public function getRegionAttr($value, $data)
    {
        return [
            'province' => Region::getNameById($data['province_id']),
            'city' => Region::getNameById($data['city_id']),
            'region' => $data['region_id'] == 0 ? '' : Region::getNameById($data['region_id']),
        ];
    }
    public function getSexAttr($value){
        $data=[10=>'未知',20=>'男',30=>'女'];
        return $data[$value];
@@ -46,6 +66,7 @@
     */
    public function add($data){
        $data['app_id']=self::$app_id;
        $data['grade_id']=(new Grade())->getDefaultGradeId();
        return $this->save($data);
    }
    public function getUnitAttr($name)
@@ -90,4 +111,13 @@
        }
        return $this->with(['user','image','logoImage'])->order($order)->where($where)->paginate($paramr);
    }
    /**
     * 获取名片详情
     * @param $business_card_id
     * @return array|false|\think\Model|null
     * @throws \think\db\exception\DbException
     */
    public function detail($business_card_id){
        return $this->with(['user','image','logoImage'])->where(['business_card_id'=>$business_card_id])->find();
    }
}