| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- use Illuminate\Support\Facades\Storage;
- class AssociateValidationResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'cpf' => $this->cpf,
- 'registration' => $this->registration,
- 'photo_url' => $this->photo_path
- ? Storage::disk('s3')->temporaryUrl($this->photo_path, now()->addHours(24))
- : null,
- 'expiry_date' => $this->expiry_date?->format('d/m/Y'),
- 'dependents' => $this->dependents->map(function ($dependent) {
- return [
- 'id' => $dependent->id,
- 'name' => $dependent->name,
- 'kinship' => $dependent->kinship,
- 'status' => $dependent->status,
- 'expiry_date' => $this->expiry_date?->format('d/m/Y'),
- ];
- })->values(),
- ];
- }
- }
|