@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | return 'email'; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if (!Validator::make(['phone' => $value], ['phone' => 'phone:ID'])->fails()) { |
|
| 23 | + if (!Validator::make([ 'phone' => $value ], [ 'phone' => 'phone:ID' ])->fails()) { |
|
| 24 | 24 | return 'phone'; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $field = static::getIdentifierField($value); |
| 39 | 39 | |
| 40 | - $rules = ['required', 'string', 'exists:' . User::class . ',' . $field]; |
|
| 40 | + $rules = [ 'required', 'string', 'exists:'.User::class.','.$field ]; |
|
| 41 | 41 | |
| 42 | 42 | switch ($field) { |
| 43 | 43 | case 'email': |
| 44 | - $rules[] = 'email'; |
|
| 44 | + $rules[ ] = 'email'; |
|
| 45 | 45 | break; |
| 46 | 46 | |
| 47 | 47 | case 'phone': |
| 48 | - $rules[] = 'phone:ID'; |
|
| 48 | + $rules[ ] = 'phone:ID'; |
|
| 49 | 49 | break; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function attributes() |
| 34 | 34 | { |
| 35 | 35 | return [ |
| 36 | - 'identifier' => trans('Email') . ' / ' .trans('Phone Number') . ' / Username', |
|
| 36 | + 'identifier' => trans('Email').' / '.trans('Phone Number').' / Username', |
|
| 37 | 37 | ]; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $this->ensureIsNotRateLimited(); |
| 61 | 61 | |
| 62 | - if (! Auth::attempt(static::getCredentials($this), $this->boolean('remember'))) { |
|
| 62 | + if (!Auth::attempt(static::getCredentials($this), $this->boolean('remember'))) { |
|
| 63 | 63 | RateLimiter::hit($this->throttleKey()); |
| 64 | 64 | |
| 65 | 65 | throw ValidationException::withMessages([ |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function ensureIsNotRateLimited() |
| 81 | 81 | { |
| 82 | - if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { |
|
| 82 | + if (!RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -102,6 +102,6 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function throttleKey() |
| 104 | 104 | { |
| 105 | - return Str::lower($this->input('email')) . '|'. $this->ip(); |
|
| 105 | + return Str::lower($this->input('email')).'|'.$this->ip(); |
|
| 106 | 106 | } |
| 107 | 107 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->displayValidationErrorMessage($validationErrorMessage); |
| 36 | 36 | |
| 37 | - return $this->askRenderable('conversations.login.ask-identifier', function (Answer $answer) { |
|
| 37 | + return $this->askRenderable('conversations.login.ask-identifier', function(Answer $answer) { |
|
| 38 | 38 | if (trim($answer->getText()) === $this->cancelText()) { |
| 39 | 39 | return $this->cancelLogin(); |
| 40 | 40 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | return $this->askIdentifier($validator->errors()->first('identifier')); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $this->setUserStorage(['credential_identifier' => $validator->validated()['identifier']]); |
|
| 49 | + $this->setUserStorage([ 'credential_identifier' => $validator->validated()[ 'identifier' ] ]); |
|
| 50 | 50 | |
| 51 | 51 | return $this->askPassword(); |
| 52 | 52 | }, additionalParameters: Keyboard::create(Keyboard::TYPE_KEYBOARD)->addRow( |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $this->displayValidationErrorMessage($validationErrorMessage); |
| 66 | 66 | |
| 67 | - return $this->askRenderable('conversations.login.ask-password', function (Answer $answer) { |
|
| 67 | + return $this->askRenderable('conversations.login.ask-password', function(Answer $answer) { |
|
| 68 | 68 | if (trim($answer->getText()) === $this->cancelText()) { |
| 69 | 69 | return $this->cancelLogin(); |
| 70 | 70 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | return $this->askPassword($validator->errors()->first('password')); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $this->setUserStorage(['credential_password' => $validator->validated()['password']]); |
|
| 79 | + $this->setUserStorage([ 'credential_password' => $validator->validated()[ 'password' ] ]); |
|
| 80 | 80 | |
| 81 | 81 | return $this->runLogin(); |
| 82 | 82 | }); |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | return $this->askIdentifier(trans('auth.failed')); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return $this->sayRenderable('conversations.login.alert-success', additionalParameters: ['reply_markup' => json_encode([ |
|
| 111 | + return $this->sayRenderable('conversations.login.alert-success', additionalParameters: [ 'reply_markup' => json_encode([ |
|
| 112 | 112 | 'remove_keyboard' => true, |
| 113 | - ])]); |
|
| 113 | + ]) ]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function cancelLogin() |
| 132 | 132 | { |
| 133 | - return $this->sayRenderable('conversations.login.alert-cancel', additionalParameters: ['reply_markup' => json_encode([ |
|
| 133 | + return $this->sayRenderable('conversations.login.alert-cancel', additionalParameters: [ 'reply_markup' => json_encode([ |
|
| 134 | 134 | 'remove_keyboard' => true, |
| 135 | - ])]); |
|
| 135 | + ]) ]); |
|
| 136 | 136 | } |
| 137 | 137 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -11,6 +11,6 @@ |
||
| 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 | } |
@@ -18,7 +18,7 @@ |
||
| 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 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -13,8 +13,8 @@ |
||
| 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 |
@@ -18,14 +18,14 @@ |
||
| 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(); |