Fix Laravel Pint formatting

This commit is contained in:
root
2026-06-09 00:03:03 -04:00
parent 8d4d610b82
commit b5fd4a4ca1
1414 changed files with 11317 additions and 10201 deletions
@@ -9,20 +9,18 @@ use App\Models\StudentClass;
use App\Models\TeacherClass;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class InventoryTeacherDistributionService
{
public function __construct(
private InventoryContextService $context,
private InventoryMovementService $movementService
) {
}
) {}
public function formData(int $userId, ?int $classSectionId, ?int $itemId): array
{
$ctx = $this->buildTeacherClassContext($userId);
if (!$ctx['ok']) {
if (! $ctx['ok']) {
return $ctx;
}
@@ -33,7 +31,7 @@ class InventoryTeacherDistributionService
: (int) ($classSectionId ?? ($ctx['defaultClassSectionId'] ?? 0));
$classID = null;
if (!empty($selectedClassId)) {
if (! empty($selectedClassId)) {
$classID = ClassSection::getClassId($selectedClassId);
$classID = $classID !== null ? (int) $classID : null;
}
@@ -43,7 +41,7 @@ class InventoryTeacherDistributionService
->leftJoin('inventory_categories as c', 'c.id', '=', 'i.category_id')
->where('i.type', 'book');
if (!empty($classID)) {
if (! empty($classID)) {
$builder->where(function ($q) use ($classID) {
$q->where(function ($inner) use ($classID) {
$inner->whereNotNull('c.grade_min')
@@ -68,27 +66,34 @@ class InventoryTeacherDistributionService
$name = $r['category_name'] ?? 'Uncategorized';
$gmin = $r['grade_min'] ?? null;
$gmax = $r['grade_max'] ?? null;
if ($gmin === null && $gmax === null) return $name;
if ($gmin !== null && $gmax !== null) return $name . ' (G' . (int) $gmin . 'G' . (int) $gmax . ')';
if ($gmin !== null) return $name . ' (G' . (int) $gmin . '+)';
return $name . ' (≤G' . (int) $gmax . ')';
if ($gmin === null && $gmax === null) {
return $name;
}
if ($gmin !== null && $gmax !== null) {
return $name.' (G'.(int) $gmin.'G'.(int) $gmax.')';
}
if ($gmin !== null) {
return $name.' (G'.(int) $gmin.'+)';
}
return $name.' (≤G'.(int) $gmax.')';
};
$booksGrouped = [];
foreach ($rows as $r) {
$catId = (int) ($r['category_id'] ?? 0);
if (!isset($booksGrouped[$catId])) {
if (! isset($booksGrouped[$catId])) {
$booksGrouped[$catId] = [
'label' => $labelFor($r),
'items' => [],
];
}
$display = $r['name'];
if (!empty($r['isbn'])) {
$display .= ' — ISBN ' . $r['isbn'];
if (! empty($r['isbn'])) {
$display .= ' — ISBN '.$r['isbn'];
}
if (!empty($r['edition'])) {
$display .= ' (' . $r['edition'] . ')';
if (! empty($r['edition'])) {
$display .= ' ('.$r['edition'].')';
}
$booksGrouped[$catId]['items'][] = [
@@ -123,7 +128,9 @@ class InventoryTeacherDistributionService
->all();
foreach ($rowsHist as $r) {
$sid = (int) ($r['student_id'] ?? 0);
if ($sid) $already[$sid] = (int) ($r['qty'] ?? 0);
if ($sid) {
$already[$sid] = (int) ($r['qty'] ?? 0);
}
}
}
@@ -154,7 +161,7 @@ class InventoryTeacherDistributionService
public function distribute(int $userId, array $payload): array
{
$ctx = $this->buildTeacherClassContext($userId);
if (!$ctx['ok']) {
if (! $ctx['ok']) {
return $ctx;
}
@@ -168,12 +175,12 @@ class InventoryTeacherDistributionService
? (int) $classIds[0]
: (in_array($postedClassId, $classIds, true) ? $postedClassId : 0);
if (!$classSectionId) {
if (! $classSectionId) {
return ['ok' => false, 'message' => 'Invalid class selection.'];
}
$book = InventoryItem::query()->find($itemId);
if (!$book || $book->type !== 'book') {
if (! $book || $book->type !== 'book') {
return ['ok' => false, 'message' => 'Invalid book.'];
}
@@ -181,7 +188,9 @@ class InventoryTeacherDistributionService
$validIds = [];
foreach ($students as $st) {
$sid = $st['student_id'] ?? ($st['id'] ?? null);
if ($sid) $validIds[(int) $sid] = true;
if ($sid) {
$validIds[(int) $sid] = true;
}
}
$selectedIds = array_values(array_filter($selectedIds, fn ($sid) => isset($validIds[$sid])));
@@ -200,7 +209,9 @@ class InventoryTeacherDistributionService
->all();
foreach ($rows as $r) {
$sid = (int) ($r['student_id'] ?? 0);
if ($sid) $already[$sid] = (int) ($r['qty'] ?? 0);
if ($sid) {
$already[$sid] = (int) ($r['qty'] ?? 0);
}
}
$toGive = [];
@@ -243,7 +254,7 @@ class InventoryTeacherDistributionService
}
$user = User::query()->find($userId);
if (!$user) {
if (! $user) {
return ['ok' => false, 'message' => 'User not found.'];
}
@@ -253,13 +264,13 @@ class InventoryTeacherDistributionService
->pluck('r.name')
->toArray();
if (!in_array('teacher', $roles, true) && !in_array('teacher_assistant', $roles, true)) {
if (! in_array('teacher', $roles, true) && ! in_array('teacher_assistant', $roles, true)) {
return ['ok' => false, 'message' => 'Access denied.'];
}
$classSectionIds = array_column($classes, 'class_section_id');
$studentsData = [];
if (!empty($classSectionIds)) {
if (! empty($classSectionIds)) {
$students = StudentClass::getStudentsByClassSectionIds($classSectionIds);
foreach ($students as $student) {
$studentsData[$student['class_section_id']][] = $student;
@@ -278,7 +289,7 @@ class InventoryTeacherDistributionService
$taUser = User::query()->find($ta['teacher_id'] ?? 0);
if ($taUser) {
$csid = $ta['class_section_id'];
$taNames[$csid][] = trim(($taUser->firstname ?? '') . ' ' . ($taUser->lastname ?? ''));
$taNames[$csid][] = trim(($taUser->firstname ?? '').' '.($taUser->lastname ?? ''));
}
}