Files
alrahma_sunday_school_api/app/Http/Resources/Incidents/IncidentAnalysisStudentResource.php
T
2026-03-09 02:52:13 -04:00

25 lines
858 B
PHP

<?php
namespace App\Http\Resources\Incidents;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class IncidentAnalysisStudentResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'student_id' => $this->resource['student_id'] ?? null,
'student_name' => $this->resource['student_name'] ?? null,
'grade' => $this->resource['grade'] ?? null,
'total' => (int) ($this->resource['total'] ?? 0),
'open' => (int) ($this->resource['open'] ?? 0),
'closed' => (int) ($this->resource['closed'] ?? 0),
'canceled' => (int) ($this->resource['canceled'] ?? 0),
'last_incident' => $this->resource['last_incident'] ?? null,
'logs' => $this->resource['logs'] ?? [],
];
}
}