Fix Pint formatting
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Services\ClassProgress;
|
||||
use App\Models\ClassProgressAttachment;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ClassProgressAttachmentService
|
||||
{
|
||||
@@ -17,7 +16,7 @@ class ClassProgressAttachmentService
|
||||
|
||||
$stored = [];
|
||||
foreach ($files as $file) {
|
||||
if (!$file instanceof UploadedFile || !$file->isValid()) {
|
||||
if (! $file instanceof UploadedFile || ! $file->isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -49,17 +48,17 @@ class ClassProgressAttachmentService
|
||||
$candidates = [];
|
||||
if (str_starts_with($path, 'storage/')) {
|
||||
$relative = ltrim(substr($path, strlen('storage/')), '/');
|
||||
$candidates[] = storage_path('app/public/' . $relative);
|
||||
$candidates[] = storage_path('app/public/'.$relative);
|
||||
}
|
||||
|
||||
if (str_starts_with($path, 'writable/uploads/')) {
|
||||
$relative = ltrim(substr($path, strlen('writable/uploads/')), '/');
|
||||
$candidates[] = storage_path('app/' . $relative);
|
||||
$candidates[] = storage_path('app/public/' . $relative);
|
||||
$candidates[] = storage_path('app/'.$relative);
|
||||
$candidates[] = storage_path('app/public/'.$relative);
|
||||
}
|
||||
|
||||
$candidates[] = storage_path('app/' . ltrim($path, '/'));
|
||||
$candidates[] = storage_path('app/public/' . ltrim($path, '/'));
|
||||
$candidates[] = storage_path('app/'.ltrim($path, '/'));
|
||||
$candidates[] = storage_path('app/public/'.ltrim($path, '/'));
|
||||
|
||||
foreach ($candidates as $candidate) {
|
||||
if (is_file($candidate)) {
|
||||
@@ -84,6 +83,6 @@ class ClassProgressAttachmentService
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return 'storage/' . ltrim($path, '/');
|
||||
return 'storage/'.ltrim($path, '/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class ClassProgressMetaService
|
||||
|
||||
public function curriculumOptions(?int $classId, ?string $schoolYear = null): array
|
||||
{
|
||||
if (!$classId) {
|
||||
if (! $classId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ use App\Models\ClassProgressReport;
|
||||
use App\Models\TeacherClass;
|
||||
use App\Models\User;
|
||||
use App\Services\SchoolYears\SchoolYearContextService;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ClassProgressMutationService
|
||||
{
|
||||
@@ -34,11 +35,11 @@ class ClassProgressMutationService
|
||||
$weekStart = (string) ($payload['week_start'] ?? '');
|
||||
$weekEnd = $this->rules->ensureWeekEnd($weekStart, $payload['week_end'] ?? null);
|
||||
|
||||
if (!$this->rules->isWeekEndValid($weekStart, $weekEnd)) {
|
||||
if (! $this->rules->isWeekEndValid($weekStart, $weekEnd)) {
|
||||
throw new \InvalidArgumentException('Week end must be the same as or after the week start.');
|
||||
}
|
||||
|
||||
if (!$this->rules->hasIslamicUnitSelection($payload)) {
|
||||
if (! $this->rules->hasIslamicUnitSelection($payload)) {
|
||||
throw new \InvalidArgumentException('Please select at least one Islamic Studies unit.');
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ class ClassProgressMutationService
|
||||
->values()
|
||||
->all();
|
||||
|
||||
if ($existingIds !== [] && !$confirmOverwrite) {
|
||||
if ($existingIds !== [] && ! $confirmOverwrite) {
|
||||
throw new \InvalidArgumentException('CONFIRM_OVERWRITE');
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ class ClassProgressMutationService
|
||||
throw new \InvalidArgumentException('Please select at least one Islamic Studies unit.');
|
||||
}
|
||||
|
||||
$originalWeekStart = $anchor->week_start instanceof \Carbon\CarbonInterface
|
||||
$originalWeekStart = $anchor->week_start instanceof CarbonInterface
|
||||
? $anchor->week_start->format('Y-m-d')
|
||||
: (string) $anchor->week_start;
|
||||
|
||||
@@ -295,7 +296,7 @@ class ClassProgressMutationService
|
||||
return DB::transaction(function () use ($report, $payload, $attachments) {
|
||||
$weekStart = $payload['week_start'] ?? $report->week_start?->format('Y-m-d');
|
||||
$weekEnd = $this->rules->ensureWeekEnd((string) $weekStart, $payload['week_end'] ?? null);
|
||||
if ($weekStart && $weekEnd && !$this->rules->isWeekEndValid((string) $weekStart, (string) $weekEnd)) {
|
||||
if ($weekStart && $weekEnd && ! $this->rules->isWeekEndValid((string) $weekStart, (string) $weekEnd)) {
|
||||
throw new \InvalidArgumentException('Week end must be the same as or after the week start.');
|
||||
}
|
||||
|
||||
@@ -364,7 +365,7 @@ class ClassProgressMutationService
|
||||
->where('class_section_id', $classSectionId)
|
||||
->exists();
|
||||
|
||||
if (!$assigned) {
|
||||
if (! $assigned) {
|
||||
throw new \InvalidArgumentException('No class assignment found for this report.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ use App\Models\Configuration;
|
||||
use App\Models\TeacherClass;
|
||||
use App\Models\User;
|
||||
use App\Services\SchoolYears\SchoolYearContextService;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ClassProgressQueryService
|
||||
{
|
||||
@@ -28,7 +28,7 @@ class ClassProgressQueryService
|
||||
->with(['classSection', 'teacher'])
|
||||
->orderBy($filters['sort_by'] ?? 'week_start', $filters['sort_dir'] ?? 'desc');
|
||||
|
||||
if (!$this->isAdmin($user)) {
|
||||
if (! $this->isAdmin($user)) {
|
||||
$relaxedSectionIds = TeacherClass::distinctSectionIdsForTeacher((int) $user->id);
|
||||
|
||||
if (! empty($filters['class_section_id'])) {
|
||||
@@ -50,31 +50,31 @@ class ClassProgressQueryService
|
||||
$query->where('teacher_id', (int) $filters['teacher_id']);
|
||||
}
|
||||
|
||||
if (!empty($filters['class_section_id'])) {
|
||||
if (! empty($filters['class_section_id'])) {
|
||||
$query->where('class_section_id', (int) $filters['class_section_id']);
|
||||
}
|
||||
|
||||
if (!empty($filters['subject'])) {
|
||||
if (! empty($filters['subject'])) {
|
||||
$query->where('subject', (string) $filters['subject']);
|
||||
}
|
||||
|
||||
if (!empty($filters['status'])) {
|
||||
if (! empty($filters['status'])) {
|
||||
$query->where('status', (string) $filters['status']);
|
||||
}
|
||||
|
||||
if (!empty($filters['school_year']) && Schema::hasColumn('class_progress_reports', 'school_year')) {
|
||||
if (! empty($filters['school_year']) && Schema::hasColumn('class_progress_reports', 'school_year')) {
|
||||
$query->where('school_year', (string) $filters['school_year']);
|
||||
}
|
||||
|
||||
if (!empty($filters['semester']) && Schema::hasColumn('class_progress_reports', 'semester')) {
|
||||
if (! empty($filters['semester']) && Schema::hasColumn('class_progress_reports', 'semester')) {
|
||||
$query->where('semester', (string) $filters['semester']);
|
||||
}
|
||||
|
||||
if (!empty($filters['week_start'])) {
|
||||
if (! empty($filters['week_start'])) {
|
||||
$query->whereDate('week_start', '>=', $filters['week_start']);
|
||||
}
|
||||
|
||||
if (!empty($filters['week_end'])) {
|
||||
if (! empty($filters['week_end'])) {
|
||||
$query->whereDate('week_end', '<=', $filters['week_end']);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ class ClassProgressQueryService
|
||||
return $rows->map(function (ClassProgressReport $row) use ($attachments) {
|
||||
$row->setAttribute('status_label', $this->statusLabel($row->status));
|
||||
$row->setAttribute('attachments', $attachments[$row->id] ?? []);
|
||||
|
||||
return $row;
|
||||
})->all();
|
||||
}
|
||||
@@ -159,6 +160,7 @@ class ClassProgressQueryService
|
||||
private function statusLabel(?string $status): string
|
||||
{
|
||||
$options = (array) config('progress.status_options', []);
|
||||
|
||||
return $options[$status] ?? 'Unknown';
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ class ClassProgressRuleService
|
||||
public function normalizeFlags($flags): ?array
|
||||
{
|
||||
$values = array_values(array_filter((array) $flags, static fn ($item) => $item !== '' && $item !== null));
|
||||
|
||||
return $values === [] ? null : $values;
|
||||
}
|
||||
|
||||
@@ -80,6 +81,7 @@ class ClassProgressRuleService
|
||||
try {
|
||||
$dt = new \DateTime($weekStart);
|
||||
$dt->modify('+6 days');
|
||||
|
||||
return $dt->format('Y-m-d');
|
||||
} catch (\Exception $e) {
|
||||
return $weekStart;
|
||||
|
||||
Reference in New Issue
Block a user