Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from wizaplace/feature-TMA-1313-BO-create-discu…
Browse files Browse the repository at this point in the history
…ssion-and-messages-from-an-order

TMA-1313 [BO] Create a discussion and messages from an order
  • Loading branch information
ecourtial authored Jan 19, 2022
2 parents 9fa7c60 + 5497162 commit dba6b9a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Repository/DiscussionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,36 @@ public function andWhereDiscussionFilter(QueryBuilder $queryBuilder, $user_id =

return $queryBuilder;
}

/**
* Get a discussion by order Id
*
* @param integer $orderId
*
* @return DiscussionInterface | null
*
* @throws \Exception
*/
public function getByOrderId(int $orderId)
{
$qb = $this->_getRepo()->createQueryBuilder('Discussion');
$expr = $qb->expr();

$query = $qb
->join(
'Discussion.meta_data',
'MetaData'
)
->where($expr->eq('MetaData.name', ':name'))
->andWhere($expr->eq('MetaData.value', ':orderId'))
->setParameters(
[
'name' => 'order_id',
'orderId' => $orderId,
]
)
->getQuery();

return $query->getOneOrNullResult();
}
}

0 comments on commit dba6b9a

Please sign in to comment.