Gender::class, 'treat_at' => 'date', 'birthday' => 'date', ]; protected function age(): Attribute { return new Attribute( get: fn () => $this->birthday ? $this->birthday->diffInYears() : '', ); } protected function sexText(): Attribute { return new Attribute( get: fn () => $this->sex ? $this->sex->text() : '', ); } protected function treatFormat(): Attribute { return new Attribute( get: fn () => $this->treat_at ? $this->treat_at->format('Y-m-d') : '', ); } protected function birthdayFormat(): Attribute { return new Attribute( get: fn () => $this->birthday ? $this->birthday->format('Y-m-d') : '', ); } public function doctor() { return $this->belongsTo(AdminUser::class, 'doctor_id'); } public function scopeSort($q) { return $q->orderBy('id', 'desc'); } }