123456789101112131415161718192021222324252627282930 |
- <?php
- namespace App\ModelFilters;
- use Carbon\Carbon;
- use EloquentFilter\ModelFilter;
- class PlanFilter extends ModelFilter
- {
-
- 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');
- });
- }
- }
|