public function scopeCreatedBetweenDates($query, array $dates)
{
$start = ($dates[0] instanceof Carbon) ? $dates[0] : Carbon::parse($dates[0]);
$end = ($dates[1] instanceof Carbon) ? $dates[1] : Carbon::parse($dates[1]);
return $query->whereBetween('created_at', [
$start->startOfDay(),
$end->endOfDay()
]);
}