Files
famous-ly4-ev/app-modules/catalog/src/Http/Resources/EvCompanyResource.php
T
Nyan Lin Paing 4f0f20659d
PHP Tests / php-tests (push) Has been cancelled
Return EvCompany logo as a full URL in the API resource
EvCompanyResource returned the raw disk-relative path stored by
Filament's FileUpload (e.g. "logos/xxx.png"), not something API
consumers can render directly.

- EvCompany::logoUrl() builds an absolute URL from the configured
  filesystem disk, guarding against a disk (e.g. s3) that already
  returns an absolute URL so it isn't double-prefixed.
- EvCompanyResource now exposes that as 'logo' instead of the raw path.
2026-08-23 23:59:13 +07:00

30 lines
742 B
PHP

<?php
namespace Modules\Catalog\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class EvCompanyResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'mm_name' => $this->mm_name,
'slug' => $this->slug,
'description' => $this->description,
'mm_description' => $this->mm_description,
'contact' => $this->contact,
'address' => $this->address,
'logo' => $this->logo_url,
];
}
}