31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class PartnerStoreResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'business_name' => $this->business_name,
|
|
'business_permit_number' => $this->business_permit_number,
|
|
'address_line' => $this->address_line,
|
|
'barangay_id' => $this->barangay_id,
|
|
'coordinates' => $this->coordinates ? [
|
|
'lat' => $this->coordinates->latitude,
|
|
'lng' => $this->coordinates->longitude,
|
|
] : null,
|
|
'commission_rate_percent' => $this->commission_rate_percent,
|
|
'status' => $this->status,
|
|
'inventory_balance' => $this->whenLoaded('inventory', fn () => $this->inventory?->current_code_balance ?? 0),
|
|
'owner' => UserResource::make($this->whenLoaded('owner')),
|
|
'barangay' => BarangayResource::make($this->whenLoaded('barangay')),
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|