machines->find($machineId); if (!$machine) { $this->mcpError('not_found', "Machine not found: {$machineId}"); } $constructeurs = []; foreach ($machine->getConstructeurs() as $c) { $constructeurs[] = [ 'id' => $c->getId(), 'name' => $c->getName(), ]; } $site = null; if ($machine->getSite()) { $site = [ 'id' => $machine->getSite()->getId(), 'name' => $machine->getSite()->getName(), ]; } return $this->jsonResponse([ 'id' => $machine->getId(), 'name' => $machine->getName(), 'reference' => $machine->getReference(), 'prix' => $machine->getPrix(), 'site' => $site, 'constructeurs' => $constructeurs, 'createdAt' => $machine->getCreatedAt()->format('Y-m-d H:i:s'), 'updatedAt' => $machine->getUpdatedAt()->format('Y-m-d H:i:s'), ]); } }