Fix Laravel Pint formatting

This commit is contained in:
root
2026-06-08 23:30:22 -04:00
parent 567dc24649
commit c792b8be05
1288 changed files with 10766 additions and 9669 deletions
+42 -32
View File
@@ -3,7 +3,6 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\DB;
@@ -21,30 +20,30 @@ class TeacherClass extends BaseModel
'updated_at',
'created_at',
];
public $timestamps = true;
protected $casts = [
'teacher_id' => 'integer',
'teacher_id' => 'integer',
'class_section_id' => 'integer',
'updated_by' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'updated_by' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/* ============================================================
* Constants
* ============================================================
*/
public const POS_MAIN = 'main';
public const POS_TA = 'ta';
public const POS_TA = 'ta';
public static function allowedPositions(): array
{
return [self::POS_MAIN, self::POS_TA];
}
/* ============================================================
* Relationships (optional)
* ============================================================
@@ -138,15 +137,15 @@ class TeacherClass extends BaseModel
return $rows->map(function ($r) use ($semester) {
return [
'class_section_pk' => isset($r->class_section_pk) ? (int) $r->class_section_pk : null,
'class_section_id' => (int) $r->class_section_id,
'class_section_pk' => isset($r->class_section_pk) ? (int) $r->class_section_pk : null,
'class_section_id' => (int) $r->class_section_id,
'class_section_name' => (string) $r->class_section_name,
'class_id' => isset($r->class_id) ? (int) $r->class_id : null,
'class_name' => $r->class_name ?? null,
'teacher_id' => (int) $r->teacher_id,
'teacher_role' => ucfirst((string) $r->position), // Main / Ta
'school_year' => (string) $r->school_year,
'semester' => $semester,
'class_id' => isset($r->class_id) ? (int) $r->class_id : null,
'class_name' => $r->class_name ?? null,
'teacher_id' => (int) $r->teacher_id,
'teacher_role' => ucfirst((string) $r->position), // Main / Ta
'school_year' => (string) $r->school_year,
'semester' => $semester,
];
})->all();
}
@@ -214,15 +213,21 @@ class TeacherClass extends BaseModel
$classSectionName = trim($classSectionName);
if (str_contains($classSectionName, ',')) {
$parts = array_values(array_filter(array_map('trim', explode(',', $classSectionName))));
if (!empty($parts)) $classSectionName = $parts[0];
if (! empty($parts)) {
$classSectionName = $parts[0];
}
}
if ($classSectionName === '') {
return null;
}
if ($classSectionName === '') return null;
$sectionCode = DB::table('classSection')
->where('class_section_name', $classSectionName)
->value('class_section_id');
if (!$sectionCode) return null;
if (! $sectionCode) {
return null;
}
$teacherId = DB::table('teacher_class')
->where('class_section_id', $sectionCode)
@@ -264,7 +269,7 @@ class TeacherClass extends BaseModel
?int $updatedBy = null
): bool {
$position = strtolower(trim($position));
if (!in_array($position, self::allowedPositions(), true)) {
if (! in_array($position, self::allowedPositions(), true)) {
throw new \InvalidArgumentException('Position must be either "main" or "ta".');
}
@@ -272,10 +277,10 @@ class TeacherClass extends BaseModel
static::query()->updateOrCreate(
[
'teacher_id' => $teacherId,
'teacher_id' => $teacherId,
'class_section_id' => $sectionCode,
'school_year' => $schoolYear,
'position' => $position,
'school_year' => $schoolYear,
'position' => $position,
],
[
'updated_by' => $updatedBy,
@@ -309,7 +314,7 @@ class TeacherClass extends BaseModel
* Returns rows: class_section_id, teacher_id, position, firstname, lastname
*
* @param int|null $alsoSectionCode When teacher_class rows use the section PK while $sectionCode
* is the business code (or the reverse), pass the other id.
* is the business code (or the reverse), pass the other id.
* @param bool $requireSemester When false, ignore semester (legacy DBs with blank/wrong tc.semester).
*/
public static function assignedForSectionTerm(
@@ -360,6 +365,7 @@ class TeacherClass extends BaseModel
foreach (static::assignedForSectionTerm($sectionCode, $semester, $schoolYear, $alsoSectionCode, $requireSemester) as $r) {
$out[(int) $r['teacher_id']] = $r;
}
return $out;
}
@@ -377,9 +383,11 @@ class TeacherClass extends BaseModel
->orderByRaw("CASE tc.position WHEN 'main' THEN 0 WHEN 'ta' THEN 1 ELSE 2 END")
->orderBy('u.firstname', 'asc');
if (!empty($onlySectionCodes)) {
if (! empty($onlySectionCodes)) {
$ids = array_values(array_unique(array_filter(array_map('intval', $onlySectionCodes))));
if (!empty($ids)) $q->whereIn('tc.class_section_id', $ids);
if (! empty($ids)) {
$q->whereIn('tc.class_section_id', $ids);
}
}
$rows = $q->get()->map(fn ($r) => (array) $r)->all();
@@ -387,7 +395,9 @@ class TeacherClass extends BaseModel
$out = [];
foreach ($rows as $r) {
$code = (int) ($r['class_section_id'] ?? 0);
if ($code <= 0) continue;
if ($code <= 0) {
continue;
}
$out[$code][] = $r;
}
@@ -403,12 +413,12 @@ class TeacherClass extends BaseModel
$req = $updating ? 'sometimes' : 'required';
return [
'teacher_id' => [$req, 'integer', 'min:1', 'exists:users,id'],
'teacher_id' => [$req, 'integer', 'min:1', 'exists:users,id'],
'class_section_id' => [$req, 'integer', 'min:1'],
'semester' => [$req, 'string', 'max:25'],
'school_year' => [$req, 'string', 'max:9'],
'position' => [$req, 'string', 'in:' . implode(',', self::allowedPositions())],
'updated_by' => ['nullable', 'integer'],
'semester' => [$req, 'string', 'max:25'],
'school_year' => [$req, 'string', 'max:9'],
'position' => [$req, 'string', 'in:'.implode(',', self::allowedPositions())],
'updated_by' => ['nullable', 'integer'],
];
}
}