PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
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 6 years ago CustomerBookingEventTicketRepository.php 1 year ago EventPeriodsRepository.php 4 years ago EventProvidersRepository.php 6 years ago EventRepository.php 1 year ago EventTagsRepository.php 6 years ago EventTicketRepository.php 1 year ago
CustomerBookingEventPeriodRepository.php
99 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
18 const FACTORY = CustomerBookingEventPeriod::class;
19
20 /**
21 * @param CustomerBookingEventPeriod $entity
22 *
23 * @return bool
24 * @throws QueryExecutionException
25 */
26 public function add($entity)
27 {
28 $data = $entity->toArray();
29
30 $params = [
31 ':eventPeriodId' => $data['eventPeriodId'],
32 ':customerBookingId' => $data['customerBookingId'],
33 ];
34
35 try {
36 $statement = $this->connection->prepare(
37 "INSERT INTO {$this->table}
38 (
39 `eventPeriodId`,
40 `customerBookingId`
41 )
42 VALUES (
43 :eventPeriodId,
44 :customerBookingId
45 )"
46 );
47
48 $res = $statement->execute($params);
49
50 if (!$res) {
51 throw new QueryExecutionException('Unable to add data in ' . __CLASS__);
52 }
53
54 return $this->connection->lastInsertId();
55 } catch (\Exception $e) {
56 throw new QueryExecutionException('Unable to add data in ' . __CLASS__, $e->getCode(), $e);
57 }
58 }
59
60 /**
61 * @param int $id
62 * @param CustomerBookingEventPeriod $entity
63 *
64 * @return mixed
65 * @throws QueryExecutionException
66 */
67 public function update($id, $entity)
68 {
69 $data = $entity->toArray();
70
71 $params = [
72 ':id' => $id,
73 ':eventPeriodId' => $data['eventPeriodId'],
74 ':customerBookingId' => $data['customerBookingId'],
75 ];
76
77 try {
78 $statement = $this->connection->prepare(
79 "UPDATE {$this->table}
80 SET
81 `eventPeriodId` = :eventPeriodId,
82 `customerBookingId` = :customerBookingId
83 WHERE id = :id"
84 );
85
86 $res = $statement->execute($params);
87
88 if (!$res) {
89 throw new QueryExecutionException('Unable to save data in ' . __CLASS__);
90 }
91
92 return $res;
93 } catch (\Exception $e) {
94 throw new QueryExecutionException('Unable to save data in ' . __CLASS__, $e->getCode(), $e);
95 }
96 }
97
98 }
99