Fix Laravel Pint formatting
This commit is contained in:
@@ -27,24 +27,24 @@ class AttendanceService
|
||||
|
||||
public function currentSemester(): string
|
||||
{
|
||||
return (string)($this->configuration->getConfig('semester') ?? 'Fall');
|
||||
return (string) ($this->configuration->getConfig('semester') ?? 'Fall');
|
||||
}
|
||||
|
||||
public function currentSchoolYear(): string
|
||||
{
|
||||
return (string)($this->configuration->getConfig('school_year') ?? now()->year . '-' . (now()->year + 1));
|
||||
return (string) ($this->configuration->getConfig('school_year') ?? now()->year.'-'.(now()->year + 1));
|
||||
}
|
||||
|
||||
public function updateAttendanceManagement(Authenticatable $user, array $data): array
|
||||
{
|
||||
$classSectionId = (int)$data['class_section_id'];
|
||||
$studentId = (int)$data['student_id'];
|
||||
$status = strtolower((string)$data['status']);
|
||||
$date = (string)$data['date'];
|
||||
$classSectionId = (int) $data['class_section_id'];
|
||||
$studentId = (int) $data['student_id'];
|
||||
$status = strtolower((string) $data['status']);
|
||||
$date = (string) $data['date'];
|
||||
$reason = $data['reason'] ?? null;
|
||||
$classId = $data['class_id'] ?? null;
|
||||
$semester = (string)($data['semester'] ?? $this->currentSemester());
|
||||
$schoolYear = (string)($data['school_year'] ?? $this->currentSchoolYear());
|
||||
$semester = (string) ($data['semester'] ?? $this->currentSemester());
|
||||
$schoolYear = (string) ($data['school_year'] ?? $this->currentSchoolYear());
|
||||
|
||||
$dayRow = AttendanceDay::query()
|
||||
->where('class_section_id', $classSectionId)
|
||||
@@ -67,11 +67,11 @@ class AttendanceService
|
||||
'permissions' => method_exists($user, 'permissions') ? $user->permissions->pluck('name')->all() : [],
|
||||
];
|
||||
|
||||
if (!$this->attendancePolicyService->canEditDay($dayPolicyRow, $currentUser)) {
|
||||
if (! $this->attendancePolicyService->canEditDay($dayPolicyRow, $currentUser)) {
|
||||
throw new RuntimeException('Attendance is locked for your role.');
|
||||
}
|
||||
|
||||
$reportedRaw = strtolower((string)($data['is_reported'] ?? ''));
|
||||
$reportedRaw = strtolower((string) ($data['is_reported'] ?? ''));
|
||||
$isReported = $status === 'present'
|
||||
? 'no'
|
||||
: (in_array($reportedRaw, ['1', 'yes', 'y', 'true', 'on'], true) ? 'yes' : 'no');
|
||||
@@ -98,7 +98,7 @@ class AttendanceService
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
'date' => $date,
|
||||
'class_id' => (int)$classId,
|
||||
'class_id' => (int) $classId,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
@@ -136,13 +136,13 @@ class AttendanceService
|
||||
|
||||
public function adminAddEntry(Authenticatable $user, array $data): array
|
||||
{
|
||||
$classSectionId = (int)$data['class_section_id'];
|
||||
$studentId = (int)$data['student_id'];
|
||||
$status = strtolower((string)$data['status']);
|
||||
$date = (string)($data['date'] ?? now()->toDateString());
|
||||
$classSectionId = (int) $data['class_section_id'];
|
||||
$studentId = (int) $data['student_id'];
|
||||
$status = strtolower((string) $data['status']);
|
||||
$date = (string) ($data['date'] ?? now()->toDateString());
|
||||
$reason = $data['reason'] ?? null;
|
||||
$isReported = in_array(strtolower((string)($data['is_reported'] ?? 'no')), ['yes', 'no'], true)
|
||||
? strtolower((string)($data['is_reported'] ?? 'no'))
|
||||
$isReported = in_array(strtolower((string) ($data['is_reported'] ?? 'no')), ['yes', 'no'], true)
|
||||
? strtolower((string) ($data['is_reported'] ?? 'no'))
|
||||
: 'no';
|
||||
|
||||
$section = $this->classSection
|
||||
@@ -152,7 +152,7 @@ class AttendanceService
|
||||
->orWhere('class_section_id', $classSectionId)
|
||||
->first();
|
||||
|
||||
$resolvedClassId = (int)($section->class_id ?? 0);
|
||||
$resolvedClassId = (int) ($section->class_id ?? 0);
|
||||
|
||||
if ($resolvedClassId <= 0) {
|
||||
throw new RuntimeException('Cannot resolve class_id for this section.');
|
||||
@@ -210,29 +210,32 @@ class AttendanceService
|
||||
$reportedRaw = $row['is_reported'] ?? ($row['reported'] ?? '');
|
||||
$row['is_reported'] = $this->normalizeReportedFlag($reportedRaw);
|
||||
}
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function normalizeStatus(?string $status): string
|
||||
{
|
||||
$status = strtolower(trim((string)$status));
|
||||
$status = strtolower(trim((string) $status));
|
||||
|
||||
return in_array($status, ['present', 'absent', 'late'], true) ? $status : $status;
|
||||
}
|
||||
|
||||
public function normalizeReportedFlag(mixed $flag): string
|
||||
{
|
||||
$v = strtolower(trim((string)$flag));
|
||||
$v = strtolower(trim((string) $flag));
|
||||
|
||||
return in_array($v, ['yes', '1', 'true', 'y', 'on'], true) ? 'yes' : 'no';
|
||||
}
|
||||
|
||||
public function detectExternalSubmission(?array $row): array
|
||||
{
|
||||
if (empty($row) || !is_array($row)) {
|
||||
if (empty($row) || ! is_array($row)) {
|
||||
return ['locked' => false, 'source' => null];
|
||||
}
|
||||
|
||||
$reportedRaw = strtolower((string)($row['is_reported'] ?? ''));
|
||||
$reason = strtolower((string)($row['reason'] ?? ''));
|
||||
$reportedRaw = strtolower((string) ($row['is_reported'] ?? ''));
|
||||
$reason = strtolower((string) ($row['reason'] ?? ''));
|
||||
|
||||
$isParent = in_array($reportedRaw, ['yes', '1', 'true', 'y'], true)
|
||||
|| str_contains($reason, 'parent-reported')
|
||||
@@ -242,7 +245,7 @@ class AttendanceService
|
||||
return ['locked' => true, 'source' => 'parent'];
|
||||
}
|
||||
|
||||
$modifierId = (int)($row['modified_by'] ?? 0);
|
||||
$modifierId = (int) ($row['modified_by'] ?? 0);
|
||||
if ($modifierId > 0 && $this->isAdminLikeUserId($modifierId)) {
|
||||
return ['locked' => true, 'source' => 'admin'];
|
||||
}
|
||||
@@ -264,12 +267,12 @@ class AttendanceService
|
||||
$excluded = ['parent', 'guest', 'teacher', 'teacher_assistant', 'assistant_teacher', 'ta'];
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$name = strtolower(str_replace([' ', '-'], '_', (string)($role['role_name'] ?? '')));
|
||||
if ($name !== '' && !in_array($name, $excluded, true)) {
|
||||
$name = strtolower(str_replace([' ', '-'], '_', (string) ($role['role_name'] ?? '')));
|
||||
if ($name !== '' && ! in_array($name, $excluded, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user