From d97be45086dfee81b9f43d021471858ea5197e9c Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Tue, 16 May 2023 11:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=8D=E6=A4=8D=E8=AE=B0=E5=BD=95id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Filters/Admin/PlantHarvestLogFilter.php | 3 ++- app/Http/Controllers/Api/RegionController.php | 2 +- app/Models/PlantHarvestLog.php | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Filters/Admin/PlantHarvestLogFilter.php b/app/Filters/Admin/PlantHarvestLogFilter.php index 53b94f6..1839d24 100644 --- a/app/Filters/Admin/PlantHarvestLogFilter.php +++ b/app/Filters/Admin/PlantHarvestLogFilter.php @@ -9,7 +9,8 @@ class PlantHarvestLogFilter extends ModelFilter /** * 所属种植计划 */ - public function plant($plantId){ + public function plant($plantId) + { return $this->where('plant_id', $plantId); } } diff --git a/app/Http/Controllers/Api/RegionController.php b/app/Http/Controllers/Api/RegionController.php index b501f93..a9738b6 100644 --- a/app/Http/Controllers/Api/RegionController.php +++ b/app/Http/Controllers/Api/RegionController.php @@ -51,7 +51,7 @@ class RegionController extends Controller public function harvests($id, Request $request) { $info = Region::show()->findOrFail($id); - $query = $info->harvests(); + $query = $info->harvests()->filter($request->all()); $per = $request->input('per_page'); if ($per == -1) { $list = $query->get(); diff --git a/app/Models/PlantHarvestLog.php b/app/Models/PlantHarvestLog.php index 947aac6..4776f73 100644 --- a/app/Models/PlantHarvestLog.php +++ b/app/Models/PlantHarvestLog.php @@ -13,7 +13,13 @@ class PlantHarvestLog extends Model 'harvest_at' => 'datetime:Y-m-d', ]; - public function plant(){ + public function plant() + { return $this->belongsTo(RegionPlantLog::class, 'plant_id'); } + + public function modelFilter() + { + return \App\Filters\Admin\PlantHarvestLogFilter::class; + } }