2017-11-28 1 views
-1

바우처 엔티티에서 금액 값을 얻으려면 어떻게해야합니까?symfony 컨트롤러에서 오브젝트 값을 얻는 방법

금액이 비어있는 경우 조건을 추가하고 데이터베이스에 값을 삽입하지 않으려합니다.

getVouchers() 엔터티

["vouchers":"AppBundle\Entity\Participant":private]=> 
    object(Doctrine\Common\Collections\ArrayCollection)#985 (1) { 
    ["elements":"Doctrine\Common\Collections\ArrayCollection":private]=> 
    array(7) { 
     [0]=> 
     object(AppBundle\Entity\Product)#993 (9) { 
     ["id":"AppBundle\Entity\Product":private]=> 
     NULL 
     ["description":"AppBundle\Entity\Product":private]=> 
     NULL 
     ["amount":"AppBundle\Entity\Product":private]=> 
     string(1) "1" 
     ["alreadyWon":"AppBundle\Entity\Product":private]=> 
     NULL 
     ["value":"AppBundle\Entity\Product":private]=> 
     string(4) "2,50" 
     ["discountPrice":"AppBundle\Entity\Product":private]=> 
     NULL 
     ["image":"AppBundle\Entity\Product":private]=> 
     NULL 
     ["participant":"AppBundle\Entity\Product":private]=> 
     *RECURSION* 
     ["participant_voucher":"AppBundle\Entity\Product":private]=> 
     NULL 
     } 

답변

0

getVouchers()에 배열 컬렉션이 있습니다.

은 왜 당신은 ..... 이런 식으로

foreach(getVouchers() as $voucher){ 
    if (empty($voucher->getAmount())) { 
     //your logic 
    }else{ 
     // 
    } 
} 
+0

getAmount()는 엔티티 아니다 시도하지 않습니다. – Umakant

+0

어? 그래서? 귀하의 의견은 이해가되지 않습니다 ... 어쨌든 당신은 당신이 데이터베이스에 삽입하고 싶지 않은 가치에 대해 더 구체적으로 말할 수 있습니까? 금액 값 또는 전체 바우처 엔티티일까요? – OlivierC

관련 문제