'datetime:Y-m-d', 'end_at' => 'datetime:Y-m-d', ]; //1进行中,2已结束 protected function plantState():Attribute { return Attribute::make( get:fn($value, $attributes) => $attributes['end_at'] ? 2:1, ); } public function harvestes(){ return $this->hasMany(PlantHarvestLog::class, 'plant_id'); } }