From 726376efeac721e6cb8d3002a3782f9e4b96dc0f Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Tue, 13 Jan 2026 17:31:45 +0800 Subject: [PATCH] update --- app/Models/User.php | 59 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index d2b7590..da1ec05 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -77,15 +77,35 @@ class User extends Authenticatable implements Auditable 'open_course_types', 'talent_tags' ]; - protected $appends = ['is_vip_text', 'is_schoolmate_text', 'appointment_total', 'name']; + protected $appends = ['is_vip_text', 'is_schoolmate_text', 'appointment_total', 'name', 'is_company_schoolmate', 'is_company_schoolmate_text']; // 更新时候覆盖更新的字段 public static $coverFields = [ - 'name', 'sex', 'mobile', 'company_has_share', 'company_name', 'school', 'speciality', - 'birthday', 'mobile', 'idcard', 'education', 'company_date', 'sales_volume', 'valuation', - 'market_value', 'is_yuanhe', 'username', - 'company_position', 'company_need_fund', 'company_address', 'company_area', - 'course_id', 'status', 'fee_status', 'is_vip' + 'name', + 'sex', + 'mobile', + 'company_has_share', + 'company_name', + 'school', + 'speciality', + 'birthday', + 'mobile', + 'idcard', + 'education', + 'company_date', + 'sales_volume', + 'valuation', + 'market_value', + 'is_yuanhe', + 'username', + 'company_position', + 'company_need_fund', + 'company_address', + 'company_area', + 'course_id', + 'status', + 'fee_status', + 'is_vip' ]; public function getNameAttribute($value) @@ -127,6 +147,33 @@ class User extends Authenticatable implements Auditable return self::$intToString['is_schoolmate'][$this->is_schoolmate] ?? '否'; } + /** + * 获取是否校友企业(数字:0否1是) + * 查询学员对应的企业下的用户,是否包含校友 + */ + public function getIsCompanySchoolmateAttribute($value) + { + // 如果学员没有关联企业,返回否 + if (empty($this->company_id)) { + return 0; + } + + // 查询该企业下是否有校友(is_schoolmate = 1) + $hasSchoolmate = self::where('company_id', $this->company_id) + ->where('is_schoolmate', 1) + ->exists(); + + return $hasSchoolmate ? 1 : 0; + } + + /** + * 获取是否校友企业(文本:是/否) + */ + public function getIsCompanySchoolmateTextAttribute($value) + { + return $this->is_company_schoolmate == 1 ? '是' : '否'; + } + /** * 数据类型转换,数字转字符串。 * 值是id则是数据字典的顶级id,或者是枚举型数组