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; + } }