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