@@ -67,7 +67,7 @@ private function createOrUpdateGlobalPeriod(): void
6767
6868 is_null ($ projection ) ?
6969 $ this ->createGlobalProjection () :
70- $ this ->updateProjection ($ projection );
70+ $ this ->updateProjection ($ projection, ' * ' );
7171 }
7272
7373 /**
@@ -79,7 +79,7 @@ private function parsePeriod(string $period): void
7979
8080 is_null ($ projection ) ?
8181 $ this ->createProjection ($ period ) :
82- $ this ->updateProjection ($ projection );
82+ $ this ->updateProjection ($ projection, $ period );
8383 }
8484
8585 /**
@@ -118,7 +118,7 @@ private function createProjection(string $period): void
118118 'key ' => $ this ->hasKey () ? $ this ->key () : null ,
119119 'period ' => $ period ,
120120 'start_date ' => app (Quasar::class)->resolveFloorDate ($ this ->projectedModel ->created_at , $ period ),
121- 'content ' => $ this ->mergeProjectedContent ((new $ this ->projectionName ())->defaultContent ()),
121+ 'content ' => $ this ->mergeProjectedContent ((new $ this ->projectionName ())->defaultContent (), $ period ),
122122 ]);
123123 }
124124
@@ -132,16 +132,16 @@ private function createGlobalProjection()
132132 'key ' => $ this ->hasKey () ? $ this ->key () : null ,
133133 'period ' => '* ' ,
134134 'start_date ' => null ,
135- 'content ' => $ this ->mergeProjectedContent ((new $ this ->projectionName ())->defaultContent ()),
135+ 'content ' => $ this ->mergeProjectedContent ((new $ this ->projectionName ())->defaultContent (), ' * ' ),
136136 ]);
137137 }
138138
139139 /**
140140 * Updates the projection.
141141 */
142- private function updateProjection (Projection $ projection ): void
142+ private function updateProjection (Projection $ projection, string $ period ): void
143143 {
144- $ projection ->content = $ this ->mergeProjectedContent ($ projection ->content );
144+ $ projection ->content = $ this ->mergeProjectedContent ($ projection ->content , $ period );
145145
146146 $ projection ->save ();
147147 }
@@ -157,9 +157,9 @@ private function hasKey(): bool
157157 /**
158158 * Merges the projected content with the given one.
159159 */
160- private function mergeProjectedContent (array $ content ): array
160+ private function mergeProjectedContent (array $ content, string $ period ): array
161161 {
162- return array_merge ($ content , $ this ->resolveCallableMethod ($ content ));
162+ return array_merge ($ content , $ this ->resolveCallableMethod ($ content, $ period ));
163163 }
164164
165165 /**
@@ -177,15 +177,15 @@ private function hasCallableMethod(): bool
177177 /**
178178 * Resolves the callable method.
179179 */
180- private function resolveCallableMethod (array $ content ): array
180+ private function resolveCallableMethod (array $ content, string $ period ): array
181181 {
182182 $ modelName = Str::of ($ this ->projectedModel ::class)->explode ('\\' )->last ();
183183 $ callableMethod = lcfirst ($ modelName ) . ucfirst ($ this ->eventName );
184184 $ defaultCallable = 'projectable ' . ucfirst ($ this ->eventName );
185185
186186 return method_exists ($ this ->projectionName , $ callableMethod ) ?
187- (new $ this ->projectionName ())->$ callableMethod ($ content , $ this ->projectedModel ) :
188- (new $ this ->projectionName ())->$ defaultCallable ($ content , $ this ->projectedModel );
187+ (new $ this ->projectionName ())->$ callableMethod ($ content , $ this ->projectedModel , $ period ) :
188+ (new $ this ->projectionName ())->$ defaultCallable ($ content , $ this ->projectedModel , $ period );
189189 }
190190
191191 /**
0 commit comments