Here is my code :
Controller :
$userOrder = $doctrineOrderRepository->getOrders(Auth::id());
Doctrine:
public function getUserOrders( $userId ) :array
{
$results = $this->_em->createQueryBuilder()
->select( 'o.restaurantId as rtId, o.oCount, o.oPrice ,
o.oCreated', 'o.oId' )
->from( $this->entityClass, 'o' )
->where( "o.userId = '{$userId}'" )
->andWhere( "o.orderItemCount > '0'" )
->andWhere( "o.orderTotalPrice > '0'" )
->getQuery()->getArrayResult();
return $results;
}
I get this array from my database Using Doctrine :
array:1 [▼
0 => array:5 [▼
"rtId" => 154
"oCount" => 2
"oPrice" => 33900
"oCreated" => DateTime {#677 ▶}
"oId" => 17428
]
]
I'm using this Doctrine method in different situations. In this case , I just use two item of all list : rtId , oCount
So , how to modify $userOrder to convert result array to this bellow array?
array:1 [▼
0 => array:2 [▼
"rtId" => 154
"oCount" => 2
]
]