@@ -37,13 +37,13 @@ |
||
37 | 37 | public function handle(DomainMessage $domainMessage) |
38 | 38 | { |
39 | 39 | $this->queue->push(QueueToEventDispatcher::class, |
40 | - [ |
|
41 | - 'uuid' => (string)$domainMessage->getId(), |
|
42 | - 'playhead' => $domainMessage->getPlayHead(), |
|
43 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
44 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
45 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
46 | - 'type' => $domainMessage->getType(), |
|
47 | - ]); |
|
40 | + [ |
|
41 | + 'uuid' => (string)$domainMessage->getId(), |
|
42 | + 'playhead' => $domainMessage->getPlayHead(), |
|
43 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
44 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
45 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
46 | + 'type' => $domainMessage->getType(), |
|
47 | + ]); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | public function handle() |
49 | 49 | { |
50 | 50 | if ($this->option('force') == 'true' || $this->confirm("Are you sure you want to make a new table '{$this->config->get('cqrses.eventstore_table')}'" |
51 | - . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
52 | - . " Do you wish to continue?") |
|
51 | + . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
52 | + . " Do you wish to continue?") |
|
53 | 53 | ) { |
54 | 54 | return $this->buildEventStoreTable(); |
55 | 55 | } |
@@ -62,16 +62,16 @@ discard block |
||
62 | 62 | protected function buildEventStoreTable() |
63 | 63 | { |
64 | 64 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
65 | - ->create($this->config->get('cqrses.eventstore_table'), |
|
66 | - function (Blueprint $table) { |
|
67 | - $table->increments('id'); |
|
68 | - $table->string('uuid', 56); |
|
69 | - $table->integer('playhead')->unsigned(); |
|
70 | - $table->text('metadata'); |
|
71 | - $table->text('payload'); |
|
72 | - $table->string('recorded_on', 32); |
|
73 | - $table->text('type'); |
|
74 | - $table->unique(['uuid', 'playhead']); |
|
75 | - }); |
|
65 | + ->create($this->config->get('cqrses.eventstore_table'), |
|
66 | + function (Blueprint $table) { |
|
67 | + $table->increments('id'); |
|
68 | + $table->string('uuid', 56); |
|
69 | + $table->integer('playhead')->unsigned(); |
|
70 | + $table->text('metadata'); |
|
71 | + $table->text('payload'); |
|
72 | + $table->string('recorded_on', 32); |
|
73 | + $table->text('type'); |
|
74 | + $table->unique(['uuid', 'playhead']); |
|
75 | + }); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | \ No newline at end of file |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public function load($id) |
55 | 55 | { |
56 | 56 | $rows = $this->db->table($this->eventStoreTableName) |
57 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
58 | - ->where('uuid', $id) |
|
59 | - ->orderBy('playhead', 'asc') |
|
60 | - ->get(); |
|
57 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
58 | + ->where('uuid', $id) |
|
59 | + ->orderBy('playhead', 'asc') |
|
60 | + ->get(); |
|
61 | 61 | $events = []; |
62 | 62 | |
63 | 63 | foreach ($rows as $row) { |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | { |
102 | 102 | try { |
103 | 103 | $this->db->table($this->eventStoreTableName) |
104 | - ->insert( |
|
105 | - [ |
|
106 | - 'uuid' => (string)$domainMessage->getId(), |
|
107 | - 'playhead' => $domainMessage->getPlayHead(), |
|
108 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
109 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
110 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
111 | - 'type' => $domainMessage->getType(), |
|
112 | - ] |
|
113 | - ); |
|
104 | + ->insert( |
|
105 | + [ |
|
106 | + 'uuid' => (string)$domainMessage->getId(), |
|
107 | + 'playhead' => $domainMessage->getPlayHead(), |
|
108 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
109 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
110 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
111 | + 'type' => $domainMessage->getType(), |
|
112 | + ] |
|
113 | + ); |
|
114 | 114 | } catch (\PDOException $ex) { |
115 | 115 | if ($ex->getCode() == 23000) { |
116 | 116 | throw new DuplicateAggregatePlayhead((string)$domainMessage->getId(), $domainMessage->getPlayHead()); |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | public function getEventsByType($eventTypes, $skip, $take) |
155 | 155 | { |
156 | 156 | $rows = $this->db->table($this->eventStoreTableName) |
157 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
158 | - ->whereIn('type', $eventTypes) |
|
159 | - ->skip($skip) |
|
160 | - ->take($take) |
|
161 | - ->orderBy('recorded_on', 'asc') |
|
162 | - ->get(); |
|
157 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
158 | + ->whereIn('type', $eventTypes) |
|
159 | + ->skip($skip) |
|
160 | + ->take($take) |
|
161 | + ->orderBy('recorded_on', 'asc') |
|
162 | + ->get(); |
|
163 | 163 | $events = []; |
164 | 164 | |
165 | 165 | foreach ($rows as $row) { |