PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.32
Booking for Appointments and Events Calendar – Amelia v1.2.32
2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / Repository / Booking / Event / CustomerBookingEventTicketRepository.php
ameliabooking / src / Infrastructure / Repository / Booking / Event Last commit date
CustomerBookingEventPeriodRepository.php 1 year ago CustomerBookingEventTicketRepository.php 1 year ago EventPeriodsRepository.php 1 year ago EventProvidersRepository.php 1 year ago EventRepository.php 1 year ago EventTagsRepository.php 1 year ago EventTicketRepository.php 1 year ago
CustomerBookingEventTicketRepository.php
110 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\Repository\Booking\Event;
4
5 use AmeliaBooking\Domain\Entity\Booking\Event\CustomerBookingEventTicket;
6 use AmeliaBooking\Domain\Entity\Booking\Event\Event;
7 use AmeliaBooking\Domain\Factory\Booking\Event\CustomerBookingEventTicketFactory;
8 use AmeliaBooking\Domain\Repository\Booking\Event\EventRepositoryInterface;
9 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
10 use AmeliaBooking\Infrastructure\Repository\AbstractRepository;
11 use AmeliaBooking\Infrastructure\WP\InstallActions\DB\Booking\CustomerBookingsTable;
12
13 /**
14 * Class CustomerBookingEventTicketRepository
15 *
16 * @package AmeliaBooking\Infrastructure\Repository\Booking\Event
17 */
18 class CustomerBookingEventTicketRepository extends AbstractRepository implements EventRepositoryInterface
19 {
20 public const FACTORY = CustomerBookingEventTicketFactory::class;
21
22 /**
23 * @param CustomerBookingEventTicket $entity
24 *
25 * @return bool
26 * @throws QueryExecutionException
27 */
28 public function add($entity)
29 {
30 $data = $entity->toArray();
31
32 $params = [
33 ':eventTicketId' => $data['eventTicketId'],
34 ':customerBookingId' => $data['customerBookingId'],
35 ':price' => $data['price'],
36 ':persons' => $data['persons']
37 ];
38
39 try {
40 $statement = $this->connection->prepare(
41 "INSERT INTO {$this->table}
42 (
43 `eventTicketId`,
44 `customerBookingId`,
45 `price`,
46 `persons`
47 )
48 VALUES (
49 :eventTicketId,
50 :customerBookingId,
51 :price,
52 :persons
53 )"
54 );
55
56 $res = $statement->execute($params);
57
58 if (!$res) {
59 throw new QueryExecutionException('Unable to add data in ' . __CLASS__);
60 }
61
62 return $this->connection->lastInsertId();
63 } catch (\Exception $e) {
64 throw new QueryExecutionException('Unable to add data in ' . __CLASS__, $e->getCode(), $e);
65 }
66 }
67
68 /**
69 * @param int $id
70 * @param Event $entity
71 *
72 * @return mixed
73 * @throws QueryExecutionException
74 */
75 public function update($id, $entity)
76 {
77 $data = $entity;
78
79 $params = [
80 ':id' => $id,
81 ':eventTicketId' => $data['eventTicketId'],
82 ':customerBookingId' => $data['customerBookingId'],
83 ':price' => $data['price'],
84 ':persons' => $data['persons'],
85 ];
86
87 try {
88 $statement = $this->connection->prepare(
89 "UPDATE {$this->table}
90 SET
91 `eventTicketId` = :eventTicketId,
92 `customerBookingId` = :customerBookingId,
93 `price` = :price,
94 `persons` = :persons
95 WHERE id = :id"
96 );
97
98 $res = $statement->execute($params);
99
100 if (!$res) {
101 throw new QueryExecutionException('Unable to save data in ' . __CLASS__);
102 }
103
104 return $res;
105 } catch (\Exception $e) {
106 throw new QueryExecutionException('Unable to save data in ' . __CLASS__, $e->getCode(), $e);
107 }
108 }
109 }
110