Fix Laravel Pint formatting
This commit is contained in:
@@ -16,7 +16,7 @@ class ClassPreparationAdjustmentWriterService
|
||||
|
||||
foreach ($adjustments as $itemName => $adjustment) {
|
||||
$item = (string) $itemName;
|
||||
if ($item === '' || !isset($allowed[$item])) {
|
||||
if ($item === '' || ! isset($allowed[$item])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class ClassPreparationAdjustmentWriterService
|
||||
'adjustable' => 1,
|
||||
]);
|
||||
$count++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class ClassPreparationCalculatorService
|
||||
|
||||
if ($numValue > 0 && $numValue < 30) {
|
||||
$firstDigit = (int) substr((string) $numValue, 0, 1);
|
||||
|
||||
return $firstDigit === 1 ? 1 : ($firstDigit === 2 ? 2 : 3);
|
||||
}
|
||||
|
||||
@@ -69,10 +70,12 @@ class ClassPreparationCalculatorService
|
||||
|
||||
if ($gradeMin !== null && $classLevel < (int) $gradeMin) {
|
||||
$items[$name] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($gradeMax !== null && $classLevel > (int) $gradeMax) {
|
||||
$items[$name] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class ClassPreparationContextService
|
||||
->count();
|
||||
|
||||
$this->rosterPresenceCache[$key] = $cnt > 0;
|
||||
|
||||
return $this->rosterPresenceCache[$key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class ClassPreparationInventoryService
|
||||
}
|
||||
|
||||
$needsFallback = array_filter($inventoryMap, static fn ($v) => (int) $v === 0);
|
||||
if (!empty($needsFallback)) {
|
||||
if (! empty($needsFallback)) {
|
||||
$fallbackRows = DB::table('inventory_items')
|
||||
->select('name AS item_name, COALESCE(SUM(CASE WHEN good_qty IS NOT NULL AND good_qty > 0 THEN good_qty WHEN `condition`=\"good\" THEN quantity ELSE quantity END),0) AS available')
|
||||
->where('type', 'classroom')
|
||||
@@ -79,6 +79,7 @@ class ClassPreparationInventoryService
|
||||
|
||||
if ($goodQty > 0) {
|
||||
$inventoryMap[$name] = $goodQty;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class ClassPreparationLogService
|
||||
'prep_data' => json_encode($items),
|
||||
'created_at' => $createdAt,
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
|
||||
@@ -13,8 +13,7 @@ class ClassPreparationPrintService
|
||||
private ClassPreparationCalculatorService $calculator,
|
||||
private ClassPreparationAdjustmentService $adjustments,
|
||||
private ClassPreparationLogService $logs
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function printPrep(string $classSectionId, string $schoolYear, ?string $semester = null): array
|
||||
{
|
||||
@@ -31,7 +30,7 @@ class ClassPreparationPrintService
|
||||
$printedAt = $this->utcNow();
|
||||
$ok = $this->logs->createLog($classSectionId, $className, $schoolYear, $items, $printedAt);
|
||||
|
||||
if (!$ok) {
|
||||
if (! $ok) {
|
||||
Log::warning('Failed to store class preparation log.', [
|
||||
'class_section_id' => $classSectionId,
|
||||
'school_year' => $schoolYear,
|
||||
@@ -55,6 +54,7 @@ class ClassPreparationPrintService
|
||||
if (function_exists('utc_now')) {
|
||||
return (string) utc_now();
|
||||
}
|
||||
|
||||
return now('UTC')->toDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class ClassPreparationRosterService
|
||||
}
|
||||
|
||||
$row = $query->first();
|
||||
|
||||
return (int) ($row->cnt ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,19 @@ use App\Models\ClassSection;
|
||||
class ClassPreparationService
|
||||
{
|
||||
private ClassPreparationContextService $context;
|
||||
|
||||
private ClassPreparationRosterService $roster;
|
||||
|
||||
private ClassPreparationInventoryService $inventory;
|
||||
|
||||
private ClassPreparationCalculatorService $calculator;
|
||||
|
||||
private ClassPreparationAdjustmentService $adjustments;
|
||||
|
||||
private ClassPreparationLogService $logs;
|
||||
|
||||
private ClassPreparationAdjustmentWriterService $adjustmentWriter;
|
||||
|
||||
private ClassPreparationPrintService $printService;
|
||||
|
||||
public function __construct(
|
||||
@@ -66,14 +73,14 @@ class ClassPreparationService
|
||||
$hasChanged = $this->logs->hasPrepChanged($baseItems, $oldPrep);
|
||||
|
||||
$results[] = [
|
||||
'class_section' => $className,
|
||||
'class_section' => $className,
|
||||
'class_section_id' => $classSectionId,
|
||||
'student_count' => $studentCount,
|
||||
'class_level' => $classLevel,
|
||||
'prep_items' => $baseItems,
|
||||
'needs_print' => $hasChanged,
|
||||
'last_printed_at' => $oldSnap?->created_at,
|
||||
'adjustments' => $adjMap,
|
||||
'student_count' => $studentCount,
|
||||
'class_level' => $classLevel,
|
||||
'prep_items' => $baseItems,
|
||||
'needs_print' => $hasChanged,
|
||||
'last_printed_at' => $oldSnap?->created_at,
|
||||
'adjustments' => $adjMap,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -139,6 +146,7 @@ class ClassPreparationService
|
||||
if (function_exists('utc_now')) {
|
||||
return (string) utc_now();
|
||||
}
|
||||
|
||||
return now('UTC')->toDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user