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
+47 -40
View File
@@ -2,9 +2,8 @@
namespace App\Models;
use App\Models\BaseModel;
use Illuminate\Support\Carbon;
use Illuminate\Database\QueryException;
use Illuminate\Support\Carbon;
class AttendanceDay extends BaseModel
{
@@ -39,20 +38,20 @@ class AttendanceDay extends BaseModel
protected $casts = [
'class_section_id' => 'integer',
'submitted_by' => 'integer',
'published_by' => 'integer',
'reopened_by' => 'integer',
'submitted_by' => 'integer',
'published_by' => 'integer',
'reopened_by' => 'integer',
// If these are DATETIME columns:
'submitted_at' => 'datetime',
'published_at' => 'datetime',
'auto_publish_at' => 'datetime',
'reopened_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'submitted_at' => 'datetime',
'published_at' => 'datetime',
'auto_publish_at' => 'datetime',
'reopened_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
// If date is stored as DATE string; if it's DATETIME, change to 'datetime'
'date' => 'date',
'date' => 'date',
];
/* =========================
@@ -75,11 +74,15 @@ class AttendanceDay extends BaseModel
->whereDate('date', $date)
->where(function ($w) {
$w->where('status', 'published')
->orWhere('status', 'finalized'); // legacy
->orWhere('status', 'finalized'); // legacy
});
if ($semester !== null) $q->where('semester', $semester);
if ($schoolYear !== null) $q->where('school_year', $schoolYear);
if ($semester !== null) {
$q->where('semester', $semester);
}
if ($schoolYear !== null) {
$q->where('school_year', $schoolYear);
}
return $q->exists();
}
@@ -113,7 +116,9 @@ class AttendanceDay extends BaseModel
int $userId = 0
): self {
$row = static::findBySectionDate($classSectionId, $date, $semester, $schoolYear);
if ($row) return $row;
if ($row) {
return $row;
}
$now = now();
$normalizedDate = Carbon::parse($date)->toDateString();
@@ -121,25 +126,27 @@ class AttendanceDay extends BaseModel
try {
return static::create([
'class_section_id' => $classSectionId,
'date' => $normalizedDate,
'status' => 'draft',
'submitted_by' => null,
'submitted_at' => null,
'published_by' => null,
'published_at' => null,
'auto_publish_at' => null,
'reopened_by' => null,
'reopened_at' => null,
'reopen_reason' => null,
'semester' => $semester,
'school_year' => $schoolYear,
'created_at' => $now,
'updated_at' => $now,
'date' => $normalizedDate,
'status' => 'draft',
'submitted_by' => null,
'submitted_at' => null,
'published_by' => null,
'published_at' => null,
'auto_publish_at' => null,
'reopened_by' => null,
'reopened_at' => null,
'reopen_reason' => null,
'semester' => $semester,
'school_year' => $schoolYear,
'created_at' => $now,
'updated_at' => $now,
]);
} catch (QueryException $e) {
// Race: someone inserted same unique key.
$row = static::findBySectionDate($classSectionId, $date, $semester, $schoolYear);
if ($row) return $row;
if ($row) {
return $row;
}
throw $e;
}
}
@@ -160,10 +167,10 @@ class AttendanceDay extends BaseModel
$now = now();
$payload = [
'status' => 'submitted',
'status' => 'submitted',
'submitted_by' => $userId,
'submitted_at' => $now,
'updated_at' => $now,
'updated_at' => $now,
];
if ($autoPublishAt !== null) {
@@ -181,10 +188,10 @@ class AttendanceDay extends BaseModel
$now = now();
return static::query()->whereKey($this->id)->update([
'status' => 'published',
'status' => 'published',
'published_by' => $userId,
'published_at' => $now,
'updated_at' => $now,
'updated_at' => $now,
]) >= 0;
}
@@ -193,18 +200,18 @@ class AttendanceDay extends BaseModel
*/
public function reopen(int $userId, string $toStatus = 'draft', ?string $reason = null): bool
{
if (!in_array($toStatus, ['draft', 'submitted'], true)) {
if (! in_array($toStatus, ['draft', 'submitted'], true)) {
throw new \InvalidArgumentException('toStatus must be "draft" or "submitted".');
}
$now = now();
return static::query()->whereKey($this->id)->update([
'status' => $toStatus,
'reopened_by' => $userId,
'reopened_at' => $now,
'status' => $toStatus,
'reopened_by' => $userId,
'reopened_at' => $now,
'reopen_reason' => $reason,
'updated_at' => $now,
'updated_at' => $now,
]) >= 0;
}
}