[input_key1, input_key2]]. * * @var array */ public $relations = []; public function expired($expired): PlanFilter { 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())->orWhereNull('end'); }); } }