Deploy / deploy (push) Successful in 15s
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>
29 lines
686 B
PHP
29 lines
686 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Resources\LotResource;
|
|
use App\Models\Batch;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class LotController extends Controller
|
|
{
|
|
public function show(string $lotNumber): LotResource|JsonResponse
|
|
{
|
|
$batch = Batch::with([
|
|
'product',
|
|
'size.packing',
|
|
'recipe.spices',
|
|
'origins.spice',
|
|
'origins.supplier',
|
|
])->where('lot_number', $lotNumber)->first();
|
|
|
|
if (! $batch) {
|
|
return response()->json(['error' => 'LOT-Nummer nicht gefunden.'], 404);
|
|
}
|
|
|
|
return new LotResource($batch);
|
|
}
|
|
}
|