Files
Verde-Web/app/Http/Resources/PublicPartnerStoreResource.php
admin 306f8fb4e8 feat(backend): customer-site API gaps + CORS
- GET /partner-stores/nearby — public, residents browse active stores
  ranked by distance via ST_Distance_Sphere; PublicPartnerStoreResource
  excludes commission rate / owner / permit (only what a buyer needs).
- GET /partner-stores/{uuid} — public details, 404 if not active.
- GET /me/collections — paginated resident QR scan history with
  optional from/to date filters.
- GET /me/upcoming-pickups — finds scheduled/in-progress trips whose
  route includes the resident's assigned drop-off point. Returns
  household_assigned: false when no household yet.
- GET /me/notifications — paginated database notifications inbox
  with unread_only filter + unread_count in meta.
- POST /me/notifications/{id}/read, POST .../mark-all-read,
  GET .../unread-count.
- config/cors.php — allow CUSTOMER_APP_URL and any EXTRA_CORS_ORIGINS
  to call the API with credentials. Same-origin admin web is
  unaffected.

202 feature tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 17:55:10 +08:00

34 lines
1.2 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* Resident-facing store payload. Excludes commission rates, owner info,
* permit number — only what a buyer needs to choose where to go.
*/
class PublicPartnerStoreResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->uuid,
'business_name' => $this->business_name,
'address_line' => $this->address_line,
'coordinates' => $this->coordinates ? [
'lat' => $this->coordinates->latitude,
'lng' => $this->coordinates->longitude,
] : null,
'inventory_balance' => $this->whenLoaded('inventory', fn () => $this->inventory?->current_code_balance ?? 0),
'has_stock' => $this->whenLoaded('inventory', fn () => ($this->inventory?->current_code_balance ?? 0) > 0),
'distance_meters' => $this->when(
isset($this->distance_meters),
fn () => round((float) $this->distance_meters, 1),
),
'barangay' => $this->whenLoaded('barangay', fn () => $this->barangay?->name),
];
}
}