PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.0.1
Booking for Appointments and Events Calendar – Amelia v2.0.1
2.4.9 2.4.8 2.4.7 2.4.6 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 / CustomerBookingEventPeriodRepository.php
ameliabooking / src / Infrastructure / Repository / Booking / Event Last commit date
CustomerBookingEventPeriodRepository.php 8 months ago CustomerBookingEventTicketRepository.php 8 months ago EventPeriodsRepository.php 8 months ago EventProvidersRepository.php 1 year ago EventRepository.php 8 months ago EventTagsRepository.php 8 months ago EventTicketRepository.php 8 months ago
CustomerBookingEventPeriodRepository.php
97 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\Repository\Booking\Event;
4
5 use AmeliaBooking\Domain\Entity\Booking\Event\CustomerBookingEventPeriod;
6 use AmeliaBooking\Domain\Repository\Booking\Event\EventRepositoryInterface;
7 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
8 use AmeliaBooking\Infrastructure\Repository\AbstractRepository;
9
10 /**
11 * Class CustomerBookingEventPeriodRepository
12 *
13 * @package AmeliaBooking\Infrastructure\Repository\Booking\Event
14 */
15 class CustomerBookingEventPeriodRepository extends AbstractRepository implements EventRepositoryInterface
16 {
17 public const FACTORY = CustomerBookingEventPeriod::class;
18
19 /**
20 * @param CustomerBookingEventPeriod $entity
21 *
22 * @return int
23 * @throws QueryExecutionException
24 */
25 public function add($entity)
26 {
27 $data = $entity->toArray();
28
29 $params = [
30 ':eventPeriodId' => $data['eventPeriodId'],
31 ':customerBookingId' => $data['customerBookingId'],
32 ];
33
34 try {
35 $statement = $this->connection->prepare(
36 "INSERT INTO {$this->table}
37 (
38 `eventPeriodId`,
39 `customerBookingId`
40 )
41 VALUES (
42 :eventPeriodId,
43 :customerBookingId
44 )"
45 );
46
47 $res = $statement->execute($params);
48
49 if (!$res) {
50 throw new QueryExecutionException('Unable to add data in ' . __CLASS__);
51 }
52
53 return $this->connection->lastInsertId();
54 } catch (\Exception $e) {
55 throw new QueryExecutionException('Unable to add data in ' . __CLASS__, $e->getCode(), $e);
56 }
57 }
58
59 /**
60 * @param int $id
61 * @param CustomerBookingEventPeriod $entity
62 *
63 * @return mixed
64 * @throws QueryExecutionException
65 */
66 public function update($id, $entity)
67 {
68 $data = $entity->toArray();
69
70 $params = [
71 ':id' => $id,
72 ':eventPeriodId' => $data['eventPeriodId'],
73 ':customerBookingId' => $data['customerBookingId'],
74 ];
75
76 try {
77 $statement = $this->connection->prepare(
78 "UPDATE {$this->table}
79 SET
80 `eventPeriodId` = :eventPeriodId,
81 `customerBookingId` = :customerBookingId
82 WHERE id = :id"
83 );
84
85 $res = $statement->execute($params);
86
87 if (!$res) {
88 throw new QueryExecutionException('Unable to save data in ' . __CLASS__);
89 }
90
91 return $res;
92 } catch (\Exception $e) {
93 throw new QueryExecutionException('Unable to save data in ' . __CLASS__, $e->getCode(), $e);
94 }
95 }
96 }
97