Passed
Push — develop ( 62f833...95decf )
by Septianata
11:22
created
app/Conversations/HomeConservation.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $keyboard = Keyboard::create(Keyboard::TYPE_INLINE)->resizeKeyboard();
26 26
 
27 27
         foreach (static::conversations(withoutStartCommand: true) as $conversation) {
28
-            $commands = Arr::wrap($conversation['command']);
28
+            $commands = Arr::wrap($conversation[ 'command' ]);
29 29
 
30 30
             $keyboard->addRow(KeyboardButton::create(Arr::last($commands))
31 31
                 ->callbackData(Arr::first($commands))
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $additionalParameters = $keyboard->toArray()
38 38
         );
39 39
 
40
-        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response) {
40
+        return $this->getBot()->storeConversation($this, next: function(Answer $answer) use ($response) {
41 41
             if (!$answer->isInteractiveMessageReply()) {
42 42
                 return;
43 43
             }
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected function getConversation(string $name): ?Conversation
62 62
     {
63
-        if (!$conversation = static::conversations(withoutStartCommand: true)->first(fn ($conversation) =>
64
-            in_array($name, Arr::wrap($conversation['command']))
63
+        if (!$conversation = static::conversations(withoutStartCommand: true)->first(fn($conversation) =>
64
+            in_array($name, Arr::wrap($conversation[ 'command' ]))
65 65
         )) {
66 66
             return null;
67 67
         }
68 68
 
69
-        return value($conversation['handler']);
69
+        return value($conversation[ 'handler' ]);
70 70
     }
71 71
 
72 72
     /**
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         return collect([
81 81
             [
82 82
                 'command' => 'start',
83
-                'handler' => fn () => new StartConservation,
83
+                'handler' => fn() => new StartConservation,
84 84
                 'description' => 'Memulai percakapan',
85 85
             ],
86 86
             [
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                     'exchange',
89 89
                     view('conversations.home.reply-menu-exchange')->render(),
90 90
                 ],
91
-                'handler' => fn () => new ExchangeConversation,
91
+                'handler' => fn() => new ExchangeConversation,
92 92
                 'description' => 'Melakukan transaksi penukaran uang',
93 93
             ],
94 94
             [
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                     'help',
97 97
                     view('conversations.home.reply-menu-help')->render(),
98 98
                 ],
99
-                'handler' => fn () => new HelpConversation,
99
+                'handler' => fn() => new HelpConversation,
100 100
                 'description' => 'Panduan cara menggunakan chatbot ini',
101 101
             ],
102 102
             [
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                     'login',
105 105
                     view('conversations.home.reply-menu-login')->render(),
106 106
                 ],
107
-                'handler' => fn () => new LoginConversation,
107
+                'handler' => fn() => new LoginConversation,
108 108
                 'description' => 'Mendaftarkan Chat ID Telegram pada akun (khusus admin dan staf)',
109 109
             ],
110 110
             [
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     'logout',
113 113
                     view('conversations.home.reply-menu-logout')->render(),
114 114
                 ],
115
-                'handler' => fn () => new LogoutConversation,
115
+                'handler' => fn() => new LogoutConversation,
116 116
                 'description' => 'Menghapus Chat ID Telegram pada akun (khusus admin dan staf)',
117 117
             ],
118 118
             [
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                     'ask_telegram_chat_id',
121 121
                     view('conversations.home.reply-menu-ask_telegram_chat_id')->render(),
122 122
                 ],
123
-                'handler' => fn () => new AskTelegramChatIdConversation,
123
+                'handler' => fn() => new AskTelegramChatIdConversation,
124 124
                 'description' => 'Mengetahui Chat ID Telegram anda',
125 125
             ],
126 126
             [
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
                     'check_order_status',
129 129
                     view('conversations.home.reply-menu-check_order_status')->render(),
130 130
                 ],
131
-                'handler' => fn () => new CheckOrderStatusConversation,
131
+                'handler' => fn() => new CheckOrderStatusConversation,
132 132
                 'description' => 'Mengetahui status transaksi penukaran uang anda',
133 133
             ],
134
-        ])->when($withoutStartCommand, fn (Collection $conversations) =>
135
-            $conversations->reject(fn ($conversation) =>
136
-                in_array('start', Arr::wrap($conversation['command']))
134
+        ])->when($withoutStartCommand, fn(Collection $conversations) =>
135
+            $conversations->reject(fn($conversation) =>
136
+                in_array('start', Arr::wrap($conversation[ 'command' ]))
137 137
             )
138 138
         );
139 139
     }
Please login to merge, or discard this patch.
app/Conversations/AskTelegramChatIdConversation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,6 +11,6 @@
 block discarded – undo
11 11
      */
12 12
     public function run()
13 13
     {
14
-        return $this->say('Berikut ini adalah chat ID anda: ' . $this->getUser()->getId());
14
+        return $this->say('Berikut ini adalah chat ID anda: '.$this->getUser()->getId());
15 15
     }
16 16
 }
Please login to merge, or discard this patch.
app/Conversations/LogoutConversation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     {
19 19
         /** @var \App\Models\User|null $user */
20 20
         if ($user = User::firstWhere('telegram_chat_id', $this->getUser()->getId())) {
21
-            $user->update(['telegram_chat_id' => null]);
21
+            $user->update([ 'telegram_chat_id' => null ]);
22 22
 
23 23
             return $this->sayRenderable('conversations.logout.alert-success');
24 24
         }
Please login to merge, or discard this patch.
app/Conversations/CheckOrderStatusConversation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $this->displayValidationErrorMessage($validationErrorMessage);
37 37
 
38
-        return $this->askRenderable('conversations.check-order-status.ask-code', function (Answer $answer) {
38
+        return $this->askRenderable('conversations.check-order-status.ask-code', function(Answer $answer) {
39 39
             if (trim($answer->getText()) === $this->cancelText()) {
40 40
                 return $this->cancelCheck();
41 41
             }
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
      */
70 70
     protected function cancelCheck()
71 71
     {
72
-        return $this->sayRenderable('conversations.check-order-status.alert-cancel', additionalParameters: ['reply_markup' => json_encode([
72
+        return $this->sayRenderable('conversations.check-order-status.alert-cancel', additionalParameters: [ 'reply_markup' => json_encode([
73 73
             'remove_keyboard' => true,
74
-        ])]);
74
+        ]) ]);
75 75
     }
76 76
 }
Please login to merge, or discard this patch.
app/Conversations/RegisterCustomerConversation.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $this->displayValidationErrorMessage($validationErrorMessage);
34 34
 
35
-        return $this->askRenderable('conversations.exchange.ask-email', function (Answer $answer) {
35
+        return $this->askRenderable('conversations.exchange.ask-email', function(Answer $answer) {
36 36
             $value = $answer->getText();
37 37
             $validator = CustomerStoreRequest::createValidator($value, 'email');
38 38
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
                 return $this->askEmail($validator->errors()->first('email'));
41 41
             }
42 42
 
43
-            $this->setUserStorage(['email' => $email = $validator->validated()['email']]);
43
+            $this->setUserStorage([ 'email' => $email = $validator->validated()[ 'email' ] ]);
44 44
 
45 45
             $username = $this->getUser()->getUsername();
46 46
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $this->displayValidationErrorMessage($validationErrorMessage);
64 64
 
65
-        return $this->askRenderable('conversations.register-customer.ask-fullname', function (Answer $answer) {
65
+        return $this->askRenderable('conversations.register-customer.ask-fullname', function(Answer $answer) {
66 66
             $value = $answer->getText();
67 67
             $validator = CustomerStoreRequest::createValidator($value, 'fullname');
68 68
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 return $this->askFullName($validator->errors()->first('fullname'));
71 71
             }
72 72
 
73
-            $this->setUserStorage(['fullname' => $validator->validated()['fullname']]);
73
+            $this->setUserStorage([ 'fullname' => $validator->validated()[ 'fullname' ] ]);
74 74
 
75 75
             return $this->askIdentityNumberOption();
76 76
         });
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
                 Button::create(view('conversations.register-customer.reply-identity_number-no')->render())->value('no'),
100 100
             ]);
101 101
 
102
-        return $this->ask($question, function (Answer $answer) {
102
+        return $this->ask($question, function(Answer $answer) {
103 103
             if (!$answer->isInteractiveMessageReply()) {
104 104
                 return;
105 105
             }
106 106
 
107
-            if (!in_array($value = $answer->getValue(), ['yes', 'no'])) {
107
+            if (!in_array($value = $answer->getValue(), [ 'yes', 'no' ])) {
108 108
                 return $this->askIdentityNumberOption($this->fallbackMessage($answer->getText()));
109 109
             }
110 110
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     protected function backToIdentityNumberOption(): string
123 123
     {
124
-        return trim(view('components.conversations.back', ['text' => 'opsi rekening/KTP'])->render());
124
+        return trim(view('components.conversations.back', [ 'text' => 'opsi rekening/KTP' ])->render());
125 125
     }
126 126
 
127 127
     /**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             $additionalParameters = $this->keyboardBackToIdentityNumberOption()->toArray()
152 152
         );
153 153
 
154
-        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response) {
154
+        return $this->getBot()->storeConversation($this, next: function(Answer $answer) use ($response) {
155 155
             if (trim($answer->getText()) === $this->backToIdentityNumberOption()) {
156 156
                 $this->deleteTelegramMessageFromResponse($response);
157 157
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 return $this->askAccountNumber($validator->errors()->first('account_number'));
166 166
             }
167 167
 
168
-            $this->setUserStorage(['account_number' => $validator->validated()['account_number']]);
168
+            $this->setUserStorage([ 'account_number' => $validator->validated()[ 'account_number' ] ]);
169 169
 
170 170
             return $this->askPhone();
171 171
         }, question: $question, additionalParameters: $additionalParameters);
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             $additionalParameters = $this->keyboardBackToIdentityNumberOption()->toArray()
187 187
         );
188 188
 
189
-        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response1) {
189
+        return $this->getBot()->storeConversation($this, next: function(Answer $answer) use ($response1) {
190 190
             if (trim($answer->getText()) === $this->backToIdentityNumberOption()) {
191 191
                 $this->deleteTelegramMessageFromResponse($response1);
192 192
 
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
                 return $this->askIdentityCard($validator->errors()->first('identitycard_number'));
201 201
             }
202 202
 
203
-            $this->setUserStorage(['identitycard_number' => $validator->validated()['identitycard_number']]);
203
+            $this->setUserStorage([ 'identitycard_number' => $validator->validated()[ 'identitycard_number' ] ]);
204 204
 
205 205
             $response2 = $this->reply(
206 206
                 $question = view('conversations.register-customer.ask-identitycard_image')->render()
207 207
             );
208 208
 
209
-            return $this->getBot()->storeConversation($this, function (Answer $answer) use ($response1, $response2) {
209
+            return $this->getBot()->storeConversation($this, function(Answer $answer) use ($response1, $response2) {
210 210
                 if (trim($answer->getText()) === $this->backToIdentityNumberOption()) {
211 211
                     $this->deleteTelegramMessageFromResponse($response1);
212 212
                     $this->deleteTelegramMessageFromResponse($response2);
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
                     return $this->askIdentityNumberOption();
215 215
                 }
216 216
 
217
-                $photos = $this->getMessagePayload('photo', []);
217
+                $photos = $this->getMessagePayload('photo', [ ]);
218 218
 
219 219
                 if (empty($photos)) {
220
-                    return $this->askIdentityCard('❌ Foto KTP ' . trans('could not be found.'));
220
+                    return $this->askIdentityCard('❌ Foto KTP '.trans('could not be found.'));
221 221
                 }
222 222
 
223 223
                 $response = $this->reply(view('components.conversations.please-wait')->render());
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
                 $this->deleteTelegramMessageFromResponse($response);
228 228
 
229 229
                 if (!$filename) {
230
-                    return $this->askIdentityCard('❌ Foto KTP ' . trans('could not be saved.'));
230
+                    return $this->askIdentityCard('❌ Foto KTP '.trans('could not be saved.'));
231 231
                 }
232 232
 
233
-                $this->setUserStorage(['identitycard_image' => $filename]);
233
+                $this->setUserStorage([ 'identitycard_image' => $filename ]);
234 234
 
235 235
                 return $this
236
-                    ->say('✅ ' . trans(':action ran successfully!', ['action' => 'Upload foto KTP']))
236
+                    ->say('✅ '.trans(':action ran successfully!', [ 'action' => 'Upload foto KTP' ]))
237 237
                     ->askPhone();
238 238
             }, $question);
239 239
         }, question: $question, additionalParameters: $additionalParameters);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $this->displayValidationErrorMessage($validationErrorMessage);
251 251
 
252
-        return $this->askRenderable('conversations.register-customer.ask-phone', function () {
252
+        return $this->askRenderable('conversations.register-customer.ask-phone', function() {
253 253
             $value = $this->getMessagePayload('contact.phone_number');
254 254
             $validator = CustomerStoreRequest::createValidator($value, 'phone');
255 255
 
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
                 return $this->askPhone($validator->errors()->first('phone'));
258 258
             }
259 259
 
260
-            $this->setUserStorage(['phone' => $validator->validated()['phone']]);
260
+            $this->setUserStorage([ 'phone' => $validator->validated()[ 'phone' ] ]);
261 261
 
262 262
             return $this->askWhatsappPhone();
263
-        }, additionalParameters: ['reply_markup' => json_encode([
264
-            'keyboard' => [[['text' => '☎️ ' . trans('Send My Phone Number'), 'request_contact' => true]]],
263
+        }, additionalParameters: [ 'reply_markup' => json_encode([
264
+            'keyboard' => [ [ [ 'text' => '☎️ '.trans('Send My Phone Number'), 'request_contact' => true ] ] ],
265 265
             'resize_keyboard' => true,
266 266
             'one_time_keyboard' => true,
267 267
             'remove_keyboard' => true,
268
-        ])]);
268
+        ]) ]);
269 269
     }
270 270
 
271 271
     /**
@@ -278,34 +278,34 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $this->displayValidationErrorMessage($validationErrorMessage);
280 280
 
281
-        $question = Question::create(view('conversations.register-customer.confirm-whatsapp_phone', ['phone' => $this->getUserStorage('phone')])->render())
281
+        $question = Question::create(view('conversations.register-customer.confirm-whatsapp_phone', [ 'phone' => $this->getUserStorage('phone') ])->render())
282 282
             ->callbackId('register_confirm_whatsapp_phone')
283 283
             ->addButtons([
284 284
                 Button::create(view('conversations.register-customer.reply-whatsapp_phone-yes')->render())->value('yes'),
285 285
                 Button::create(view('conversations.register-customer.reply-whatsapp_phone-no')->render())->value('no'),
286 286
             ]);
287 287
 
288
-        return $this->ask($question, function (Answer $answer) {
288
+        return $this->ask($question, function(Answer $answer) {
289 289
             if (!$answer->isInteractiveMessageReply()) {
290 290
                 return;
291 291
             }
292 292
 
293
-            if (!in_array($value = $answer->getValue(), ['yes', 'no'])) {
293
+            if (!in_array($value = $answer->getValue(), [ 'yes', 'no' ])) {
294 294
                 return $this->askWhatsappPhone($this->fallbackMessage($answer->getText()));
295 295
             }
296 296
 
297 297
             $phone = $this->getUserStorage('phone');
298 298
 
299 299
             if ($value === 'yes') {
300
-                $this->setUserStorage(['whatsapp_phone' => $phone]);
300
+                $this->setUserStorage([ 'whatsapp_phone' => $phone ]);
301 301
 
302 302
                 return $this->askLocation();
303 303
             }
304 304
 
305
-            return value(function (string $validationErrorMessage = null) use (&$callback) {
305
+            return value(function(string $validationErrorMessage = null) use (&$callback) {
306 306
                 $this->displayValidationErrorMessage($validationErrorMessage);
307 307
 
308
-                $this->askRenderable('conversations.register-customer.ask-whatsapp_phone', function (Answer $answer) use (&$phone, $callback) {
308
+                $this->askRenderable('conversations.register-customer.ask-whatsapp_phone', function(Answer $answer) use (&$phone, $callback) {
309 309
                     $value = $answer->getText();
310 310
                     $validator = CustomerStoreRequest::createValidator($value, 'whatsapp_phone');
311 311
 
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
                         return $callback($validator->errors()->first('whatsapp_phone'));
314 314
                     }
315 315
 
316
-                    $phone = $validator->validated()['whatsapp_phone'];
316
+                    $phone = $validator->validated()[ 'whatsapp_phone' ];
317 317
 
318
-                    $this->setUserStorage(['whatsapp_phone' => $phone]);
318
+                    $this->setUserStorage([ 'whatsapp_phone' => $phone ]);
319 319
 
320 320
                     return $this->askLocation();
321 321
                 });
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     {
334 334
         $this->displayValidationErrorMessage($validationErrorMessage);
335 335
 
336
-        return $this->askRenderable('conversations.register-customer.ask-location', function () {
336
+        return $this->askRenderable('conversations.register-customer.ask-location', function() {
337 337
             $latitude = $this->getMessagePayload('location.latitude');
338 338
             $longitude = $this->getMessagePayload('location.longitude');
339 339
 
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
             ]);
355 355
 
356 356
             return $this->askDataConfirmation();
357
-        }, additionalParameters: ['reply_markup' => json_encode([
358
-            'keyboard' => [[['text' => '
Please login to merge, or discard this patch.
app/Conversations/HelpConversation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
      */
14 14
     public function run()
15 15
     {
16
-        $conversations = HomeConservation::conversations()->mapWithKeys(fn ($conversation) =>
17
-            [Arr::first(Arr::wrap($conversation['command'])) => $conversation['description']]
16
+        $conversations = HomeConservation::conversations()->mapWithKeys(fn($conversation) =>
17
+            [ Arr::first(Arr::wrap($conversation[ 'command' ])) => $conversation[ 'description' ] ]
18 18
         );
19 19
 
20 20
         return $this
Please login to merge, or discard this patch.
database/migrations/2021_05_22_000007_create_users_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
      */
19 19
     public function up()
20 20
     {
21
-        Schema::create('users', function (Blueprint $table) {
21
+        Schema::create('users', function(Blueprint $table) {
22 22
             $table->id();
23 23
             $table->foreignIdFor(Branch::class)->constrained()->onUpdate('cascade')->onDelete('cascade');
24 24
 
25 25
             $table->string('telegram_chat_id')->nullable()->unique();
26 26
             $table->string('username');
27 27
             $table->string('fullname');
28
-            $table->string('gender')->default(Gender::undefined())->comment('Enum of ' . Gender::class);
28
+            $table->string('gender')->default(Gender::undefined())->comment('Enum of '.Gender::class);
29 29
             $table->string('email')->unique();
30 30
             $table->string('phone_country')->default(env('PHONE_COUNTRY', 'ID'));
31 31
             $table->string('phone')->unique();
Please login to merge, or discard this patch.
routes/botman.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@
 block discarded – undo
19 19
 $botman = resolve('botman');
20 20
 
21 21
 foreach (HomeConservation::conversations() as $conversation) {
22
-    $commands = Arr::wrap($conversation['command']);
22
+    $commands = Arr::wrap($conversation[ 'command' ]);
23 23
 
24
-    data_set($commands, 0, '/' . data_get($commands, 0));
24
+    data_set($commands, 0, '/'.data_get($commands, 0));
25 25
 
26
-    $botman->hears($commands, fn (BotMan $botman) => $botman->startConversation(value($conversation['handler'])));
26
+    $botman->hears($commands, fn(BotMan $botman) => $botman->startConversation(value($conversation[ 'handler' ])));
27 27
 }
28 28
 
29
-$botman->fallback(function (BotMan $botman) {
29
+$botman->fallback(function(BotMan $botman) {
30 30
     $message = __("Maaf, kami tidak mengenali maksud dari '{$botman->getMessage()->getText()}'.");
31 31
 
32 32
     $keyboard = Keyboard::create(Keyboard::TYPE_KEYBOARD)->resizeKeyboard()->oneTimeKeyboard();
Please login to merge, or discard this patch.