develop
parent
b8b4762539
commit
5811fdfb0e
|
|
@ -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')),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收货记录
|
// 收货记录
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue