CompanySettingResource.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Http\Resources;
  3. use Carbon\Carbon;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. use Illuminate\Support\Facades\Storage;
  7. class CompanySettingResource extends JsonResource
  8. {
  9. public function toArray(Request $request): array
  10. {
  11. return [
  12. 'id' => $this->id,
  13. 'hero_background_path' => $this->hero_background_path,
  14. 'hero_background_url' => $this->hero_background_path
  15. ? Storage::disk('s3')->temporaryUrl($this->hero_background_path, now()->addHours(24))
  16. : null,
  17. 'hero_title' => $this->hero_title,
  18. 'hero_subtitle' => $this->hero_subtitle,
  19. 'stat1_value' => $this->stat1_value,
  20. 'stat1_label' => $this->stat1_label,
  21. 'stat2_value' => $this->stat2_value,
  22. 'stat2_label' => $this->stat2_label,
  23. 'stat3_value' => $this->stat3_value,
  24. 'stat3_label' => $this->stat3_label,
  25. 'contact_email' => $this->contact_email,
  26. 'contact_phone' => $this->contact_phone,
  27. 'contact_location' => $this->contact_location,
  28. 'updated_at' => $this->updated_at
  29. ? Carbon::parse($this->updated_at)->format('Y-m-d H:i:s')
  30. : null,
  31. ];
  32. }
  33. }