1 <?php
2
3 namespace PLus\Orders\Repositories\Order;
4
5
6
7 8 9 10 11
12 class InvestmentchatRepository extends \PLus\Orders\Repositories\Repository {
13
14
15 16 17 18 19
20 public function findById($id) {
21 return $this->getTable()
22 ->select('investmentchat.*')->wherePrimary($id)->fetch();
23 }
24
25
26 27 28 29 30 31
32 public function getByOrderId($order_id) {
33 return $this->getTable()
34 ->select('investmentchat.*,ichattype.name')
35 ->where('investment.order.id', $order_id);
36 }
37
38 39 40 41 42 43 44
45 public function findChatPostsByOrderId($order_id, $ichattype_id) {
46 return $this->getTable()
47 ->select('investmentchat.*,CONCAT_WS(\' \', user.firstname, user.lastname) AS uname')
48 ->where('investment.order.id', $order_id)
49 ->where('ichattype_id', $ichattype_id);
50 }
51
52 53 54 55 56 57 58
59 public function getCountBadge($order_id, $ichattype_id) {
60 return $this->getTable()
61 ->select('COUNT(*) AS cnt')
62 ->where('investment.order.id', $order_id)
63 ->where('ichattype_id', $ichattype_id)
64 ->fetch();
65 }
66
67 }
68