@@ -52,12 +52,14 @@ protected function handleInteractive(): int
52
52
$ title = $ this ->ask ('Notification title ' );
53
53
if (empty ($ title )) {
54
54
$ this ->error ('Title is required ' );
55
+
55
56
return self ::FAILURE ;
56
57
}
57
58
58
59
$ message = $ this ->ask ('Notification message ' );
59
60
if (empty ($ message )) {
60
61
$ this ->error ('Message is required ' );
62
+
61
63
return self ::FAILURE ;
62
64
}
63
65
@@ -73,16 +75,17 @@ protected function handleInteractive(): int
73
75
} elseif ($ target === 'user ' ) {
74
76
$ userType = $ this ->choice ('Select user type ' , ['customer ' , 'admin ' ]);
75
77
$ userId = $ this ->ask ('Enter user ID ' );
76
- if (!is_numeric ($ userId )) {
78
+ if (! is_numeric ($ userId )) {
77
79
$ this ->error ('User ID must be numeric ' );
80
+
78
81
return self ::FAILURE ;
79
82
}
80
83
$ targetValue = $ userId ;
81
84
}
82
85
83
86
$ actionUrl = $ this ->ask ('Action URL (optional) ' );
84
87
$ imageUrl = $ this ->ask ('Image URL (optional) ' );
85
-
88
+
86
89
$ addData = $ this ->confirm ('Add custom data? ' , false );
87
90
$ data = null ;
88
91
if ($ addData ) {
@@ -91,6 +94,7 @@ protected function handleInteractive(): int
91
94
$ data = json_decode ($ dataInput , true );
92
95
if (json_last_error () !== JSON_ERROR_NONE ) {
93
96
$ this ->error ('Invalid JSON data ' );
97
+
94
98
return self ::FAILURE ;
95
99
}
96
100
}
@@ -99,8 +103,9 @@ protected function handleInteractive(): int
99
103
$ schedule = null ;
100
104
if ($ this ->confirm ('Schedule notification? ' , false )) {
101
105
$ schedule = $ this ->ask ('Schedule time (Y-m-d H:i:s format) ' );
102
- if ($ schedule && !strtotime ($ schedule )) {
106
+ if ($ schedule && ! strtotime ($ schedule )) {
103
107
$ this ->error ('Invalid date format ' );
108
+
104
109
return self ::FAILURE ;
105
110
}
106
111
}
@@ -131,6 +136,7 @@ protected function handleNonInteractive(): int
131
136
132
137
if (empty ($ title ) || empty ($ message )) {
133
138
$ this ->error ('Title and message are required. Use --title and --message options or run with --interactive ' );
139
+
134
140
return self ::FAILURE ;
135
141
}
136
142
@@ -140,6 +146,7 @@ protected function handleNonInteractive(): int
140
146
// Validate target and target-value combination
141
147
if (in_array ($ target , ['platform ' , 'user_type ' , 'user ' ]) && empty ($ targetValue )) {
142
148
$ this ->error ("Target value is required when target is ' {$ target }' " );
149
+
143
150
return self ::FAILURE ;
144
151
}
145
152
@@ -148,13 +155,15 @@ protected function handleNonInteractive(): int
148
155
$ data = json_decode ($ this ->option ('data ' ), true );
149
156
if (json_last_error () !== JSON_ERROR_NONE ) {
150
157
$ this ->error ('Invalid JSON data ' );
158
+
151
159
return self ::FAILURE ;
152
160
}
153
161
}
154
162
155
163
$ schedule = $ this ->option ('schedule ' );
156
- if ($ schedule && !strtotime ($ schedule )) {
164
+ if ($ schedule && ! strtotime ($ schedule )) {
157
165
$ this ->error ('Invalid schedule date format ' );
166
+
158
167
return self ::FAILURE ;
159
168
}
160
169
@@ -189,6 +198,7 @@ protected function sendNotification(array $notificationData): int
189
198
if (isset ($ notificationData ['scheduled_at ' ]) && $ notificationData ['scheduled_at ' ]) {
190
199
$ this ->info ("✅ Notification scheduled for: {$ notificationData ['scheduled_at ' ]}" );
191
200
$ this ->info ("Notification ID: {$ pushNotification ->id }" );
201
+
192
202
return self ::SUCCESS ;
193
203
}
194
204
@@ -205,6 +215,7 @@ protected function sendNotification(array $notificationData): int
205
215
'error ' => $ e ->getMessage (),
206
216
'data ' => $ notificationData ,
207
217
]);
218
+
208
219
return self ::FAILURE ;
209
220
}
210
221
}
@@ -226,7 +237,8 @@ protected function sendBasedOnTarget(array $notificationData): array
226
237
227
238
case 'user ' :
228
239
$ userType = $ notificationData ['user_type ' ] ?? 'customer ' ;
229
- return $ this ->pushNotificationService ->sendToUser ($ userType , (int )$ targetValue , $ notificationData );
240
+
241
+ return $ this ->pushNotificationService ->sendToUser ($ userType , (int ) $ targetValue , $ notificationData );
230
242
231
243
default :
232
244
throw new \InvalidArgumentException ("Invalid target type: {$ target }" );
@@ -236,7 +248,7 @@ protected function sendBasedOnTarget(array $notificationData): array
236
248
protected function displayResult (array $ result , PushNotification $ pushNotification ): void
237
249
{
238
250
$ this ->line ('' );
239
-
251
+
240
252
if ($ result ['success ' ]) {
241
253
$ this ->info ('✅ Notification sent successfully! ' );
242
254
} else {
0 commit comments