AssociateValidationResource.php 750 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. use Illuminate\Support\Facades\Storage;
  6. class AssociateValidationResource extends JsonResource
  7. {
  8. public function toArray(Request $request): array
  9. {
  10. return [
  11. 'id' => $this->id,
  12. 'name' => $this->name,
  13. 'cpf' => $this->cpf,
  14. 'registration' => $this->registration,
  15. 'photo_url' => $this->photo_path
  16. ? Storage::disk('s3')->temporaryUrl($this->photo_path, now()->addHours(24))
  17. : null,
  18. 'expiry_date' => $this->expiry_date?->format('d/m/Y'),
  19. ];
  20. }
  21. }