domain(); $customer = Customer::query()->create([ 'name' => $request->validated('name'), 'domain' => $domain, 'cpu' => $request->integer('cpu', config('hosting.defaults.cpu')), 'ram' => $request->integer('ram', config('hosting.defaults.ram')), 'disk' => $request->integer('disk', config('hosting.defaults.disk')), 'status' => 'pending', 'provisioning_step' => 'queued', ]); ProvisionCustomerJob::dispatch($customer->id); return response()->json([ 'message' => 'Provisioning started.', 'customer' => $customer, ], 202); } public function show(Customer $customer): JsonResponse { return response()->json(['customer' => $customer]); } public function index(): JsonResponse { return response()->json([ 'customers' => Customer::query()->latest()->get(), ]); } public function destroy(Customer $customer): JsonResponse { if ($customer->status === 'pending' && $customer->provisioning_step === 'queued') { $customer->delete(); return response()->json(['message' => 'Queued customer removed.']); } return response()->json([ 'message' => 'Use deprovision endpoint for active customers.', ], 422); } }