'json', 'business_status' => BusinessStatus::class, ]; protected $appends = ['business_status_text', 'business_status_color']; // 店长 public function master() { return $this->belongsTo(Employee::class, 'master_id'); } // 门店分类 public function category() { return $this->belongsTo(Keyword::class, 'category_id', 'key'); } // 经验分类 public function business() { return $this->belongsTo(Keyword::class, 'business_id', 'key'); } // 门店等级 public function level() { return $this->belongsTo(Keyword::class, 'level_id', 'key'); } // 门店员工 public function employees() { // role(1: 店长, 2: 店员) return $this->belongsToMany(Employee::class, 'store_employees', 'store_id', 'employee_id')->using(StoreEmployee::class); } protected function businessStatusText(): Attribute { return new Attribute( get: fn () => $this->business_status ? $this->business_status->text() : '', ); } protected function businessStatusColor(): Attribute { return new Attribute( get: fn () => $this->business_status ? $this->business_status->color() : '', ); } }