28 lines
902 B
PHP
28 lines
902 B
PHP
<?php
|
|
|
|
namespace Modules\Activity\Transformers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ActivityReportResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'activity_id' => $this->activity_id,
|
|
'activity' => new ActivityResource($this->whenLoaded('activity')),
|
|
'report_text' => $this->report_text,
|
|
'prepared_by' => $this->prepared_by,
|
|
'prepared_by_user' => $this->whenLoaded('preparedBy', fn () => [
|
|
'id' => $this->preparedBy->id,
|
|
'name' => $this->preparedBy->name,
|
|
'email' => $this->preparedBy->email,
|
|
]),
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
];
|
|
}
|
|
}
|