Files
SpiceManagementSystem/app/Http/Controllers/Api/LotController.php
T
Malek TellissiandClaude Sonnet 4.6 e14baca7e0
Deploy / deploy (push) Successful in 15s
Add LOT API v1 endpoint with full batch details
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>
2026-09-12 16:43:48 +02:00

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);
}
}