Example #1
0
 /**
  * @return array Mutates the filter values so that it is readily prepared for processing.
  */
 public function getMutatedValues()
 {
     $operator = head($this->values);
     $dates = explode(' - ', last($this->values));
     switch ($operator) {
         case 'before':
             return [DateRange::before(Carbon::createFromFormat(Filterable::$date_format, head($dates), 'GB')->startOfDay())];
         case 'in':
             return [new DateRange(Carbon::createFromFormat(Filterable::$date_format, head($dates), 'GB')->subDay()->endOfDay(), Carbon::createFromFormat(Filterable::$date_format, last($dates), 'GB')->addDay()->startOfDay())];
         case 'not_in':
             return [new DateRange(Carbon::createFromFormat(Filterable::$date_format, last($dates), 'GB')->addDay()->startOfDay(), Carbon::createFromFormat(Filterable::$date_format, head($dates), 'GB')->subDay()->endOfDay())];
         case 'after':
             return [DateRange::after(Carbon::createFromFormat(Filterable::$date_format, last($dates), 'GB')->endOfDay())];
     }
 }