1
0
Fork 0
develop
panliang 2023-05-25 16:32:45 +08:00
parent b8b4762539
commit 5811fdfb0e
2 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ class RegionResource extends JsonResource
'description' => $this->description, 'description' => $this->description,
'category_id' => $this->category_id, 'category_id' => $this->category_id,
'category' => RegionCategoryResource::make($this->whenLoaded('category')), 'category' => RegionCategoryResource::make($this->whenLoaded('category')),
'current_plant' => RegionPlantResource::make($this->whenLoaded('currentPlant')) ?: [], 'current_plant' => RegionPlantResource::make($this->whenLoaded('currentPlant')),
]; ];
} }
} }

View File

@ -56,7 +56,7 @@ class Region extends Model
// 当前种植 // 当前种植
public function currentPlant() public function currentPlant()
{ {
return $this->hasOne(RegionPlantLog::class, 'region_id')->orderBy('start_at', 'desc'); return $this->hasOne(RegionPlantLog::class, 'region_id')->whereNull('end_at')->orderBy('start_at', 'desc');
} }
// 收货记录 // 收货记录