security fix and fix parent pages
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -12,11 +12,19 @@ class ProgressGroupResource extends JsonResource
|
||||
$reports = $this['reports'] ?? [];
|
||||
|
||||
return [
|
||||
'id' => $this['id'] ?? $this['report_id'] ?? null,
|
||||
'report_id' => $this['report_id'] ?? $this['id'] ?? null,
|
||||
'view_url' => $this['view_url'] ?? null,
|
||||
'parent_view_url' => $this['parent_view_url'] ?? null,
|
||||
'week_start' => $this['week_start'] ?? null,
|
||||
'week_end' => $this['week_end'] ?? null,
|
||||
'class_section_id' => $this['class_section_id'] ?? null,
|
||||
'class_section_name' => $this['class_section_name'] ?? '',
|
||||
'reports' => $reports, // keyed by subject for compatibility
|
||||
'weekly_reports' => $this['weekly_reports'] ?? [],
|
||||
'reports_array' => $this['reports_array'] ?? [],
|
||||
'report_list' => $this['report_list'] ?? [],
|
||||
'subjects' => $this['subjects'] ?? array_keys($reports),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,20 +26,37 @@ class ClassProgressGroupCollection extends ResourceCollection
|
||||
$key = $sectionId.'|'.$weekStart;
|
||||
|
||||
if (! isset($groups[$key])) {
|
||||
$reportId = (int) $report->id;
|
||||
$groups[$key] = [
|
||||
'id' => $reportId,
|
||||
'report_id' => $reportId,
|
||||
'view_url' => url('/api/v1/class-progress/'.$reportId),
|
||||
'parent_view_url' => url('/api/v1/parents/progress/'.$reportId),
|
||||
'week_start' => $weekStart,
|
||||
'week_end' => $report->week_end?->format('Y-m-d'),
|
||||
'class_section_id' => $sectionId,
|
||||
'class_section_name' => $report->classSection?->class_section_name ?? '',
|
||||
'reports' => [],
|
||||
'weekly_reports' => [],
|
||||
'reports_array' => [],
|
||||
'report_list' => [],
|
||||
'subjects' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$groups[$key]['reports'][$report->subject] = (new ClassProgressReportResource($report))->toArray(request());
|
||||
$reportArray = (new ClassProgressReportResource($report))->toArray(request());
|
||||
$groups[$key]['reports'][$report->subject] = $reportArray;
|
||||
$groups[$key]['weekly_reports'][] = $reportArray;
|
||||
$groups[$key]['reports_array'][] = $reportArray;
|
||||
$groups[$key]['report_list'][] = $reportArray;
|
||||
$groups[$key]['subjects'][] = $report->subject;
|
||||
}
|
||||
|
||||
$items = ProgressGroupResource::collection(collect(array_values($groups)));
|
||||
|
||||
return [
|
||||
'items' => ProgressGroupResource::collection(collect(array_values($groups))),
|
||||
'items' => $items,
|
||||
'groups' => $items,
|
||||
'pagination' => [
|
||||
'current_page' => $paginator->currentPage(),
|
||||
'per_page' => $paginator->perPage(),
|
||||
|
||||
@@ -10,10 +10,59 @@ class ClassProgressShowResource extends JsonResource
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$weekly = $this['weekly_reports'] ?? [];
|
||||
$report = $this['report'];
|
||||
$reportId = (int) ($report->id ?? 0);
|
||||
$weeklyCollection = collect($weekly);
|
||||
$matchedReport = $weeklyCollection->first(fn ($weeklyReport) => (int) ($weeklyReport->id ?? 0) === $reportId);
|
||||
if ($matchedReport) {
|
||||
$report = $matchedReport;
|
||||
}
|
||||
|
||||
$weekStart = $report->week_start?->format('Y-m-d') ?? '';
|
||||
$weekEnd = $report->week_end?->format('Y-m-d');
|
||||
$sectionId = (int) ($report->class_section_id ?? 0);
|
||||
$sectionName = $report->class_section_name ?? $report->classSection?->class_section_name ?? '';
|
||||
$weeklyReports = ClassProgressReportResource::collection($weeklyCollection);
|
||||
$reports = [];
|
||||
$reportsArray = [];
|
||||
|
||||
foreach ($weekly as $weeklyReport) {
|
||||
$subject = (string) ($weeklyReport->subject ?? '');
|
||||
if ($subject === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$reportArray = (new ClassProgressReportResource($weeklyReport))->toArray($request);
|
||||
$reports[$subject] = $reportArray;
|
||||
$reportsArray[] = $reportArray;
|
||||
}
|
||||
|
||||
return [
|
||||
'report' => new ClassProgressReportResource($this['report']),
|
||||
'weekly_reports' => ClassProgressReportResource::collection(collect($weekly)),
|
||||
'id' => $reportId,
|
||||
'report_id' => $reportId,
|
||||
'view_url' => url('/api/v1/class-progress/'.$reportId),
|
||||
'parent_view_url' => url('/api/v1/parents/progress/'.$reportId),
|
||||
'report' => new ClassProgressReportResource($report),
|
||||
'weekly_reports' => $weeklyReports,
|
||||
'items' => $weeklyReports,
|
||||
'reports_array' => $reportsArray,
|
||||
'report_list' => $reportsArray,
|
||||
'reports' => $reports,
|
||||
'group' => [
|
||||
'id' => $reportId,
|
||||
'report_id' => $reportId,
|
||||
'view_url' => url('/api/v1/class-progress/'.$reportId),
|
||||
'parent_view_url' => url('/api/v1/parents/progress/'.$reportId),
|
||||
'week_start' => $weekStart,
|
||||
'week_end' => $weekEnd,
|
||||
'class_section_id' => $sectionId,
|
||||
'class_section_name' => $sectionName,
|
||||
'reports' => $reports,
|
||||
'weekly_reports' => $weeklyReports,
|
||||
'reports_array' => $reportsArray,
|
||||
'report_list' => $reportsArray,
|
||||
'subjects' => array_keys($reports),
|
||||
],
|
||||
'status_options' => $this['status_options'] ?? [],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user