@@ -23,19 +23,17 @@ class Response implements Responsable
2323
2424 protected $ component ;
2525 protected $ props ;
26- protected $ persisted ;
2726 protected $ rootView ;
2827 protected $ version ;
2928 protected $ viewData = [];
3029
3130 /**
3231 * @param array|Arrayable $props
3332 */
34- public function __construct (string $ component , array $ props , string $ rootView = 'app ' , string $ version = '' , array $ persisted = [] )
33+ public function __construct (string $ component , array $ props , string $ rootView = 'app ' , string $ version = '' )
3534 {
3635 $ this ->component = $ component ;
3736 $ this ->props = $ props instanceof Arrayable ? $ props ->toArray () : $ props ;
38- $ this ->persisted = $ persisted ;
3937 $ this ->rootView = $ rootView ;
4038 $ this ->version = $ version ;
4139 }
@@ -129,6 +127,8 @@ public function resolveProperties(Request $request, array $props): array
129127 $ props = $ this ->resolveExcept ($ request , $ props );
130128 }
131129
130+ $ props = $ this ->resolveAlways ($ props );
131+
132132 $ props = $ this ->resolvePropertyInstances ($ props , $ request );
133133
134134 return $ props ;
@@ -164,10 +164,7 @@ public function resolveArrayableProperties(array $props, Request $request, bool
164164 */
165165 public function resolveOnly (Request $ request , array $ props ): array
166166 {
167- $ only = array_merge (
168- array_filter (explode (', ' , $ request ->header (Header::PARTIAL_ONLY , '' ))),
169- $ this ->persisted
170- );
167+ $ only = array_filter (explode (', ' , $ request ->header (Header::PARTIAL_ONLY , '' )));
171168
172169 $ value = [];
173170
@@ -190,6 +187,21 @@ public function resolveExcept(Request $request, array $props): array
190187 return $ props ;
191188 }
192189
190+ /**
191+ * Resolve `always` properties that should always be included on all visits, regardless of "only" or "except" requests.
192+ */
193+ public function resolveAlways (array $ props ): array
194+ {
195+ $ always = array_filter ($ this ->props , static function ($ prop ) {
196+ return $ prop instanceof AlwaysProp;
197+ });
198+
199+ return array_merge (
200+ $ always ,
201+ $ props
202+ );
203+ }
204+
193205 /**
194206 * Resolve all necessary class instances in the given props.
195207 */
@@ -204,6 +216,10 @@ public function resolvePropertyInstances(array $props, Request $request): array
204216 $ value = App::call ($ value );
205217 }
206218
219+ if ($ value instanceof AlwaysProp) {
220+ $ value = App::call ($ value );
221+ }
222+
207223 if ($ value instanceof PromiseInterface) {
208224 $ value = $ value ->wait ();
209225 }
0 commit comments