Route changed to /api/v1/{lot_number}. LotResource now includes
packing details, units_produced, quantity_g and recipe version.
CORS config added for public API access. README documents the
endpoint, example response and subdomain setup instructions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
269570c7d6
commit
e14baca7e0
5 files changed
+110
-6
No files matched your search
@@ -10,15 +10,24 @@ class LotResource extends JsonResource
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'lot_number' => $this->lot_number,
|
||||
'produced_at' => $this->produced_at?->toDateString(),
|
||||
'expires_at' => $this->expires_at?->toDateString(),
|
||||
'lot_number' => $this->lot_number,
|
||||
'produced_at' => $this->produced_at?->toDateString(),
|
||||
'expires_at' => $this->expires_at?->toDateString(),
|
||||
'units_produced' => $this->units_produced,
|
||||
'quantity_g' => (float) $this->quantity_g,
|
||||
'product' => [
|
||||
'name' => $this->product->title,
|
||||
'description' => $this->product->description,
|
||||
],
|
||||
'packing' => $this->size ? [
|
||||
'name' => $this->size->packing->name,
|
||||
'size_g' => (float) $this->size->packing->size,
|
||||
'sku' => $this->size->sku,
|
||||
'gtin' => $this->size->gtin,
|
||||
] : null,
|
||||
'recipe' => [
|
||||
'name' => $this->recipe->name,
|
||||
'version' => $this->recipe->version,
|
||||
'created_at' => $this->recipe->created_at->toDateString(),
|
||||
],
|
||||
'spices' => $this->recipe->spices->map(function ($spice) {
|
||||
$origin = $this->origins->firstWhere('spice_id', $spice->id);
|
||||
|
||||
Reference in new issue
Block a user