|
@@ -18,19 +18,27 @@ class ClassResource extends JsonResource
|
|
|
public function toArray(Request $request): array
|
|
public function toArray(Request $request): array
|
|
|
{
|
|
{
|
|
|
return [
|
|
return [
|
|
|
- 'id' => $this->id,
|
|
|
|
|
- 'name' => $this->name,
|
|
|
|
|
- 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
|
|
|
|
|
- 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
|
|
|
|
|
- // Add your fields here
|
|
|
|
|
|
|
+ 'id' => $this->id,
|
|
|
|
|
+ 'title' => $this->title,
|
|
|
|
|
+ 'instructor' => $this->instructor,
|
|
|
|
|
+ 'room' => $this->room,
|
|
|
|
|
+ 'status' => $this->status,
|
|
|
|
|
+ 'unit_id' => $this->unit_id,
|
|
|
|
|
+ 'class_package_unit_id' => $this->class_package_unit_id,
|
|
|
|
|
+ 'package_name' => $this->whenLoaded('packageUnit', fn () => $this->packageUnit?->name),
|
|
|
|
|
+ 'date_time_start' => $this->date_time_start
|
|
|
|
|
+ ? Carbon::parse($this->date_time_start)->format('Y-m-d\TH:i:s')
|
|
|
|
|
+ : null,
|
|
|
|
|
+ 'date_time_end' => $this->date_time_end
|
|
|
|
|
+ ? Carbon::parse($this->date_time_end)->format('Y-m-d\TH:i:s')
|
|
|
|
|
+ : null,
|
|
|
|
|
|
|
|
- // Conditional fields
|
|
|
|
|
- // $this->mergeWhen($request->user()?->isAdmin(), [
|
|
|
|
|
- // 'internal_notes' => $this->internal_notes,
|
|
|
|
|
- // ]),
|
|
|
|
|
|
|
+ // Contadores p/ exibir no card (presentes / total de alunos)
|
|
|
|
|
+ 'students_count' => $this->students_count,
|
|
|
|
|
+ 'present_count' => $this->present_count,
|
|
|
|
|
|
|
|
- // Relationships
|
|
|
|
|
- // 'user' => new UserResource($this->whenLoaded('user')),
|
|
|
|
|
|
|
+ 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
|
|
|
|
|
+ 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|