From 0d735f631a865c455196bb65fb60314da633f6bc Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Thu, 25 May 2023 16:41:21 +0800 Subject: [PATCH] 1 --- app/Models/PlantHarvestLog.php | 3 +++ app/Services/Admin/CropPlantService.php | 9 +++++++++ 2 files changed, 12 insertions(+) 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(); + } }