Files
alrahma_sunday_school_api/app/Http/Resources/ClassProgress/ClassProgressReportResource.php
T
2026-03-12 17:27:49 -04:00

36 lines
1.4 KiB
PHP

<?php
namespace App\Http\Resources\ClassProgress;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ClassProgressReportResource extends JsonResource
{
public function toArray(Request $request): array
{
$attachments = $this->attachments ?? $this['attachments'] ?? [];
return [
'id' => $this->id,
'teacher_id' => $this->teacher_id,
'class_section_id' => $this->class_section_id,
'class_section_name' => $this->classSection?->class_section_name,
'week_start' => $this->week_start?->format('Y-m-d'),
'week_end' => $this->week_end?->format('Y-m-d'),
'subject' => $this->subject,
'unit_title' => $this->unit_title,
'covered' => $this->covered,
'homework' => $this->homework,
'status' => $this->status,
'status_label' => $this->status_label ?? (config('progress.status_options')[$this->status] ?? null),
'support_needed' => $this->support_needed,
'flags' => $this->flags_json,
'attachment_path' => $this->attachment_path,
'attachments' => ClassProgressAttachmentResource::collection(collect($attachments)),
'created_at' => $this->created_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
];
}
}