Function implementation does not work correctly at cost R$/MWh.

This commit is contained in:
Djonathan 2022-07-20 09:06:11 -03:00
parent ae15694ca6
commit b13d34a38c
2 changed files with 3 additions and 5 deletions

View File

@ -21,13 +21,13 @@ class Helpers
return $result; return $result;
} }
public static function orderByDate($result, $old_format = 'Y-m-d', $format ='M/Y', $field = 'mes'): array public static function orderByDate($result, $format ='M/Y', $field = 'mes'): array
{ {
return collect($result) return collect($result)
->transform(fn($value) => Arr::set( ->transform(fn($value) => Arr::set(
$value, $value,
$field, $field,
Carbon::createFromFormat($old_format, $value[$field])->locale('pt-BR') Carbon::createFromFormat('ym', $value[$field])->locale('pt-BR')
->translatedFormat($format))) ->translatedFormat($format)))
->all(); ->all();
} }

View File

@ -153,9 +153,7 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
->orderBy(DB::raw("mes, dad_estimado")) ->orderBy(DB::raw("mes, dad_estimado"))
->get(); ->get();
$result = Helpers::checkDate($value); return Helpers::checkDate($value);
return Helpers::orderByDate($result);
} }
} }