diff --git a/src/Http/Controllers/StatController.php b/src/Http/Controllers/StatController.php index 3edc750..c649b2a 100644 --- a/src/Http/Controllers/StatController.php +++ b/src/Http/Controllers/StatController.php @@ -22,8 +22,12 @@ public function widgetData(DataRequest $request) case 'period_total': return $modelStats->getPeriodTotal($dateFrom, $dateTo, $request->date_column); case 'group_by_count': - return $modelStats->getGroupByCount($dateFrom, $dateTo, $request->date_column, - $request->aggregate_column); + return $modelStats->getGroupByCount( + $dateFrom, + $dateTo, + $request->date_column, + $request->aggregate_column + ); default: throw new \Exception('Wigdet aggregate type not supported.'); } diff --git a/src/Http/Requests/Widgets/DataRequest.php b/src/Http/Requests/Widgets/DataRequest.php index 1f3397e..c895c0c 100644 --- a/src/Http/Requests/Widgets/DataRequest.php +++ b/src/Http/Requests/Widgets/DataRequest.php @@ -16,11 +16,11 @@ class DataRequest extends FormRequest 'daily_count', 'cumulated_daily_count', 'period_total', - 'group_by_count' + 'group_by_count', ]; const AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN = [ - 'group_by_count' + 'group_by_count', ]; /** @@ -36,7 +36,7 @@ public function rules() 'date_column' => 'required', 'date_from' => 'required|date_format:Y-m-d|before:date_to', 'date_to' => 'required|date_format:Y-m-d|after:date_from', - 'aggregate_column' => [Rule::requiredIf( in_array(request()->aggregate_type, self::AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN))], + 'aggregate_column' => [Rule::requiredIf(in_array(request()->aggregate_type, self::AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN))], ]; } diff --git a/src/Services/ModelStats.php b/src/Services/ModelStats.php index 33b3c2b..3f4f3ba 100644 --- a/src/Services/ModelStats.php +++ b/src/Services/ModelStats.php @@ -106,11 +106,11 @@ public static function fillMissingDays($data, Carbon $since, Carbon $to, $defaul foreach (array_reverse(range(0, $daysSince)) as $number) { $dateKey = $to->copy()->subDays($number)->format('Y-m-d'); - if (!isset($data[$dateKey])) { + if (! isset($data[$dateKey])) { $data[$dateKey] = $defaultValue; } - if (!is_null($cumulatedSum)) { + if (! is_null($cumulatedSum)) { $data[$dateKey] += $cumulatedSum; $cumulatedSum = $data[$dateKey]; }