Intégration reservations et mock lavage
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Http\Resources\MachineResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Machine;
|
||||
use App\Services\PricingService;
|
||||
use App\Support\WashCycleProgress;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -29,6 +30,34 @@ class MachineController extends Controller
|
||||
|
||||
return $this->success([
|
||||
'machine' => new MachineResource($machine),
|
||||
'pricing' => [
|
||||
'price' => $this->pricingService->getActivePrice($machine),
|
||||
'currency' => 'EUR',
|
||||
],
|
||||
'estimated_duration_minutes' => WashCycleProgress::estimateDurationMinutes($machine->type),
|
||||
]);
|
||||
}
|
||||
|
||||
public function lookup(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'qr_code' => ['required_without:machine_uuid', 'nullable', 'string', 'max:255'],
|
||||
'machine_uuid' => ['required_without:qr_code', 'nullable', 'uuid'],
|
||||
]);
|
||||
|
||||
$machine = $request->filled('machine_uuid')
|
||||
? Machine::query()->where('uuid', $request->string('machine_uuid')->toString())->firstOrFail()
|
||||
: Machine::query()->where('qr_code', $request->string('qr_code')->toString())->firstOrFail();
|
||||
|
||||
$machine->load('establishment');
|
||||
|
||||
return $this->success([
|
||||
'machine' => new MachineResource($machine),
|
||||
'pricing' => [
|
||||
'price' => $this->pricingService->getActivePrice($machine),
|
||||
'currency' => 'EUR',
|
||||
],
|
||||
'estimated_duration_minutes' => WashCycleProgress::estimateDurationMinutes($machine->type),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user