format('Y-m-d H:i:s'); } public function scopeSort($q) { $q->orderBy('id', 'asc'); } //户主 public function master() { return $this->belongsTo(static::class, 'master_id'); } //年龄 protected function age():Attribute { return Attribute::make( get: fn($value) => $this->birthday ? Carbon::parse($this->birthday)->diffInYears(now()).'岁' : "未知", ); } protected function nowAddress(): Attribute { return Attribute::make( get: fn($value) => $this->house_complete_address ? : $this->real_address, ); } }