diff --git a/app/Models/PlantHarvestLog.php b/app/Models/PlantHarvestLog.php index 4776f73..b98363c 100644 --- a/app/Models/PlantHarvestLog.php +++ b/app/Models/PlantHarvestLog.php @@ -5,6 +5,9 @@ namespace App\Models; use EloquentFilter\Filterable; use Illuminate\Database\Eloquent\Model; +/** + * 收获记录 + */ class PlantHarvestLog extends Model { use Filterable; diff --git a/app/Services/Admin/CropPlantService.php b/app/Services/Admin/CropPlantService.php index 7f010ed..4a9351a 100644 --- a/app/Services/Admin/CropPlantService.php +++ b/app/Services/Admin/CropPlantService.php @@ -4,6 +4,7 @@ namespace App\Services\Admin; use App\Models\RegionPlantLog; use App\Filters\Admin\RegionPlantLogFilter; +use App\Models\PlantHarvestLog; /** * @method RegionPlantLog getModel() @@ -15,4 +16,12 @@ class CropPlantService extends BaseService protected string $modelFilterName = RegionPlantLogFilter::class; + public function delete(string $ids): mixed + { + $id = explode(',', $ids); + // 同时删除收获记录 + PlantHarvestLog::whereIn('plant_id', $id)->delete(); + + return $this->query()->whereIn($this->primaryKey(), $id)->delete(); + } }