PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
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 / Schedule / TimeOutRepository.php
ameliabooking / src / Infrastructure / Repository / Schedule Last commit date
DayOffRepository.php 1 month ago PeriodLocationRepository.php 3 months ago PeriodRepository.php 3 months ago PeriodServiceRepository.php 3 months ago SpecialDayPeriodLocationRepository.php 3 months ago SpecialDayPeriodRepository.php 3 months ago SpecialDayPeriodServiceRepository.php 3 months ago SpecialDayRepository.php 3 months ago TimeOutRepository.php 3 months ago WeekDayRepository.php 3 months ago
TimeOutRepository.php
81 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\Repository\Schedule;
4
5 use AmeliaBooking\Domain\Entity\Schedule\TimeOut;
6 use AmeliaBooking\Domain\Factory\Schedule\TimeOutFactory;
7 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
8 use AmeliaBooking\Infrastructure\Repository\AbstractRepository;
9
10 /**
11 * Class TimeOutRepository
12 *
13 * @package AmeliaBooking\Infrastructure\Repository\Schedule
14 */
15 class TimeOutRepository extends AbstractRepository
16 {
17 public const FACTORY = TimeOutFactory::class;
18
19 /**
20 * @param TimeOut $entity
21 * @param int $weekDayId
22 *
23 * @return int
24 * @throws QueryExecutionException
25 */
26 public function add($entity, $weekDayId)
27 {
28 $data = $entity->toArray();
29
30 $params = [
31 ':weekDayId' => $weekDayId,
32 ':startTime' => $data['startTime'],
33 ':endTime' => $data['endTime'],
34 ];
35
36 try {
37 $statement = $this->connection->prepare(
38 "INSERT INTO {$this->table}
39 (`weekDayId`, `startTime`, `endTime`)
40 VALUES (:weekDayId, :startTime, :endTime)"
41 );
42
43 $statement->execute($params);
44 } catch (\Exception $e) {
45 throw new QueryExecutionException('Unable to add data in ' . __CLASS__ . '. ' . $e->getMessage(), $e->getCode(), $e);
46 }
47
48 return $this->connection->lastInsertId();
49 }
50
51 /**
52 * @param TimeOut $entity
53 * @param int $id
54 *
55 * @return void
56 * @throws QueryExecutionException
57 */
58 public function update($entity, $id)
59 {
60 $data = $entity->toArray();
61
62 $params = [
63 ':id' => $id,
64 ':startTime' => $data['startTime'],
65 ':endTime' => $data['endTime'],
66 ];
67
68 try {
69 $statement = $this->connection->prepare(
70 "UPDATE {$this->table}
71 SET `startTime` = :startTime, `endTime` = :endTime
72 WHERE id = :id"
73 );
74
75 $statement->execute($params);
76 } catch (\Exception $e) {
77 throw new QueryExecutionException('Unable to save data in ' . __CLASS__ . '. ' . $e->getMessage(), $e->getCode(), $e);
78 }
79 }
80 }
81