File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -258,18 +258,29 @@ public function setCondition(?string $condition): self
258
258
259
259
public function toArray ()
260
260
{
261
- return [
261
+ $ data = [
262
262
'name ' => $ this ->getName (),
263
263
'data ' => $ this ->getData (),
264
264
'notification ' => ! is_null ($ this ->getNotification ()) ? $ this ->getNotification ()->toArray () : null ,
265
265
'android ' => ! is_null ($ this ->getAndroid ()) ? $ this ->getAndroid ()->toArray () : null ,
266
266
'webpush ' => ! is_null ($ this ->getWebpush ()) ? $ this ->getWebpush ()->toArray () : null ,
267
267
'apns ' => ! is_null ($ this ->getApns ()) ? $ this ->getApns ()->toArray () : null ,
268
268
'fcm_options ' => ! is_null ($ this ->getFcmOptions ()) ? $ this ->getFcmOptions ()->toArray () : null ,
269
- 'token ' => $ this ->getToken (),
270
- 'topic ' => $ this ->getTopic (),
271
- 'condition ' => $ this ->getCondition (),
272
269
];
270
+
271
+ if ($ token = $ this ->getToken ()) {
272
+ $ data ['token ' ] = $ token ;
273
+ }
274
+
275
+ if ($ topic = $ this ->getTopic ()) {
276
+ $ data ['topic ' ] = $ topic ;
277
+ }
278
+
279
+ if ($ condition = $ this ->getCondition ()) {
280
+ $ data ['condition ' ] = $ condition ;
281
+ }
282
+
283
+ return $ data ;
273
284
}
274
285
275
286
/**
You can’t perform that action at this time.
0 commit comments