Call to a member function getId() on array | Fórum | School of Net

Deseja poder participar de nosso fórum e tirar todas as suas dúvidas?
Clique aqui e assine nosso plano de acesso ilimitado. Saiba mais.

por Adriano

2 meses, 1 semana atrás Adriano

Call to a member function getId() on array

``` public function findActive() { try { return $this->createQueryBuilder('p') ->select('p.id, p.name, p.price') ->where('p.status = :status') ->setParameter('status', true) ->getQuery() ->getResult(); } catch (Throwable $e) { $e->getMessage(); } } public function active() { try { $products = $this->productRepository->findActive(); $array = array(); /** @var Product $product */ foreach ($products as $product) { $data = array( "id" => $product->getId(), "text" => $product->getName() . ' - ' . 'R$ ' . number_format($product->getPrice(), 2, ',', '.') ); array_push($array, $data); } return $this->success($this->codeSuccess, $this->messageSuccess, $array); } catch (Throwable $e) { return $this->error($this->codeError, $this->messageError, $e->getMessage()); } } ``` más da esse erro: Call to a member function getId() on array

4 Respostas