@@ -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 |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | public function load($id) |
| 54 | 54 | { |
| 55 | 55 | $rows = $this->db->table($this->eventStoreTableName) |
| 56 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 57 | - ->where('uuid', $id) |
|
| 58 | - ->orderBy('playhead', 'asc') |
|
| 59 | - ->get(); |
|
| 56 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 57 | + ->where('uuid', $id) |
|
| 58 | + ->orderBy('playhead', 'asc') |
|
| 59 | + ->get(); |
|
| 60 | 60 | $events = []; |
| 61 | 61 | |
| 62 | 62 | foreach ($rows as $row) { |
@@ -99,16 +99,16 @@ discard block |
||
| 99 | 99 | private function insertEvent(DomainMessage $domainMessage) |
| 100 | 100 | { |
| 101 | 101 | $this->db->table($this->eventStoreTableName) |
| 102 | - ->insert( |
|
| 103 | - [ |
|
| 104 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 105 | - 'playhead' => $domainMessage->getPlayHead(), |
|
| 106 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 107 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 108 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 109 | - 'type' => $domainMessage->getType(), |
|
| 110 | - ] |
|
| 111 | - ); |
|
| 102 | + ->insert( |
|
| 103 | + [ |
|
| 104 | + 'uuid' => (string)$domainMessage->getId(), |
|
| 105 | + 'playhead' => $domainMessage->getPlayHead(), |
|
| 106 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 107 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 108 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 109 | + 'type' => $domainMessage->getType(), |
|
| 110 | + ] |
|
| 111 | + ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | public function getEventsByType($eventTypes, $skip, $take) |
| 147 | 147 | { |
| 148 | 148 | $rows = $this->db->table($this->eventStoreTableName) |
| 149 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 150 | - ->whereIn('type', $eventTypes) |
|
| 151 | - ->skip($skip) |
|
| 152 | - ->take($take) |
|
| 153 | - ->orderBy('recorded_on', 'asc') |
|
| 154 | - ->get(); |
|
| 149 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 150 | + ->whereIn('type', $eventTypes) |
|
| 151 | + ->skip($skip) |
|
| 152 | + ->take($take) |
|
| 153 | + ->orderBy('recorded_on', 'asc') |
|
| 154 | + ->get(); |
|
| 155 | 155 | $events = []; |
| 156 | 156 | |
| 157 | 157 | foreach ($rows as $row) { |