[input_key1, input_key2]]. * * @var array */ public $relations = []; public function assetId($assetId): PlanFilter { $assetIds = Asset::query()->where('path','like','%'.$assetId.'%')->pluck('id'); if ($assetIds->count() === 1 || $assetIds->isEmpty()) { // 如果没有子级,只返回该分组的需求 return $this->where('asset_id', $assetId); } return $this->whereIn('asset_id',$assetIds); } public function expired($expired) { if (! in_array($expired, ['yes', 'no'])) { return $this; } return $this->when($expired == "yes", function ($query) { return $query->where('end', "<=", Carbon::now()->toDateString()); })->when($expired == "no", function ($query) { return $query->where('end', ">", Carbon::now()->toDateString()); }); } }