@@ -48,6 +48,6 @@ |
||
| 48 | 48 | { |
| 49 | 49 | $date ??= Carbon::today(); |
| 50 | 50 | |
| 51 | - return $prefix . '-' . $date->format('Ymd') . '-' . Str::random(5); |
|
| 51 | + return $prefix.'-'.$date->format('Ymd').'-'.Str::random(5); |
|
| 52 | 52 | } |
| 53 | 53 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | protected static function bootEvent() |
| 21 | 21 | { |
| 22 | - static::creating(function (Order $model) { |
|
| 22 | + static::creating(function(Order $model) { |
|
| 23 | 23 | $model->code = $model->generateCode(); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | Button::create(view('conversations.register-customer.reply-customer_data-no')->render())->value('no'), |
| 75 | 75 | ]); |
| 76 | 76 | |
| 77 | - return $this->ask($question, next: function (Answer $answer) use ($customer) { |
|
| 77 | + return $this->ask($question, next: function(Answer $answer) use ($customer) { |
|
| 78 | 78 | if (!$answer->isInteractiveMessageReply()) { |
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!in_array($value = $answer->getValue(), ['yes', 'no'])) { |
|
| 82 | + if (!in_array($value = $answer->getValue(), [ 'yes', 'no' ])) { |
|
| 83 | 83 | return $this->displayCustomerData($customer, $this->fallbackMessage($answer->getText())); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $additionalParameters = $keyboard->toArray() |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | - return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response, $customer, $denominations) { |
|
| 123 | + return $this->getBot()->storeConversation($this, next: function(Answer $answer) use ($response, $customer, $denominations) { |
|
| 124 | 124 | if (!$answer->isInteractiveMessageReply()) { |
| 125 | 125 | return; |
| 126 | 126 | } |
@@ -131,18 +131,18 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** @var \App\Models\Order $order */ |
| 134 | - $order = Order::where('code', $this->getUserStorage('order_code'))->firstOr(function () use ($customer) { |
|
| 134 | + $order = Order::where('code', $this->getUserStorage('order_code'))->firstOr(function() use ($customer) { |
|
| 135 | 135 | $order = new Order; |
| 136 | 136 | |
| 137 | 137 | $order->setCustomerRelationValue($customer)->save(); |
| 138 | 138 | |
| 139 | - $orderStatus = new ModelOrderStatus(['status' => EnumOrderStatus::draft()]); |
|
| 139 | + $orderStatus = new ModelOrderStatus([ 'status' => EnumOrderStatus::draft() ]); |
|
| 140 | 140 | |
| 141 | 141 | $order->statuses()->save( |
| 142 | 142 | $orderStatus->setIssuerableRelationValue($customer) |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - $this->setUserStorage(['order_code' => $order->code]); |
|
| 145 | + $this->setUserStorage([ 'order_code' => $order->code ]); |
|
| 146 | 146 | |
| 147 | 147 | return $order; |
| 148 | 148 | }); |
@@ -32,7 +32,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,18 +333,18 @@ discard block |
||
| 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 | $this->setUserStorage([ |
| 338 | 338 | 'location_latitude' => $this->getMessagePayload('location.latitude'), |
| 339 | 339 | 'location_longitude' => $this->getMessagePayload('location.longitude'), |
| 340 | 340 | ]); |
| 341 | 341 | |
| 342 | 342 | return $this->askDataConfirmation(); |
| 343 | - }, additionalParameters: ['reply_markup' => json_encode([ |
|
| 344 | - 'keyboard' => [[['text' => ' |
|
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param array $additionalParameters |
| 20 | 20 | * @return $this |
| 21 | 21 | */ |
| 22 | - protected function sayRenderable($view, array $viewData = [], array $viewMergeData = [], array $additionalParameters = []) |
|
| 22 | + protected function sayRenderable($view, array $viewData = [ ], array $viewMergeData = [ ], array $additionalParameters = [ ]) |
|
| 23 | 23 | { |
| 24 | 24 | $view = $view instanceof Renderable ? $view : view($view, $viewData, $viewMergeData); |
| 25 | 25 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param array $additionalParameters |
| 39 | 39 | * @return $this |
| 40 | 40 | */ |
| 41 | - protected function askRenderable($view, $next, array $viewData = [], array $viewMergeData = [], array $additionalParameters = []) |
|
| 41 | + protected function askRenderable($view, $next, array $viewData = [ ], array $viewMergeData = [ ], array $additionalParameters = [ ]) |
|
| 42 | 42 | { |
| 43 | 43 | $view = $view instanceof Renderable ? $view : view($view, $viewData, $viewMergeData); |
| 44 | 44 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function setUserStorage(array $data, string $key = null) |
| 88 | 88 | { |
| 89 | - $this->getBot()->userStorage()->save($data,$key); |
|
| 89 | + $this->getBot()->userStorage()->save($data, $key); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | * @param bool $forceDestroy |
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | - protected function destroyUserStorage(string $key = null, array $excepts = [], bool $forceDestroy = false) |
|
| 100 | + protected function destroyUserStorage(string $key = null, array $excepts = [ ], bool $forceDestroy = false) |
|
| 101 | 101 | { |
| 102 | 102 | if (!$forceDestroy) { |
| 103 | - $excepts[] = '_previous_conversation'; |
|
| 103 | + $excepts[ ] = '_previous_conversation'; |
|
| 104 | 104 | |
| 105 | 105 | /** @var \Illuminate\Support\Collection $storage */ |
| 106 | 106 | $storage = $this->getUserStorage(); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | protected function displayValidationErrorMessage(string $validationErrorMessage = null) |
| 138 | 138 | { |
| 139 | 139 | if ($validationErrorMessage) { |
| 140 | - $this->say('⛔️ ' . $validationErrorMessage); |
|
| 140 | + $this->say('⛔️ '.$validationErrorMessage); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $this; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | if (is_a($conversation, BaseConversation::class)) { |
| 193 | 193 | $conversation = is_object($conversation) ? get_class($conversation) : $conversation; |
| 194 | 194 | |
| 195 | - $this->setUserStorage(['_previous_conversation' => $conversation]); |
|
| 195 | + $this->setUserStorage([ '_previous_conversation' => $conversation ]); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | return $this; |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param \Closure|null $callback |
| 232 | 232 | * @return \Symfony\Component\HttpFoundation\Response |
| 233 | 233 | */ |
| 234 | - protected function reply($message, array $additionalParameters = [], Closure $callback = null) |
|
| 234 | + protected function reply($message, array $additionalParameters = [ ], Closure $callback = null) |
|
| 235 | 235 | { |
| 236 | 236 | $response = $this->getBot()->reply($message, $additionalParameters); |
| 237 | 237 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use Illuminate\Support\Str; |
| 8 | 8 | use Propaganistas\LaravelPhone\PhoneNumber; |
| 9 | 9 | |
| 10 | -if (! function_exists('terbilang')) { |
|
| 10 | +if (!function_exists('terbilang')) { |
|
| 11 | 11 | /** |
| 12 | 12 | * Return the given value into readable number. |
| 13 | 13 | * |
@@ -16,49 +16,49 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function terbilang($value): string |
| 18 | 18 | { |
| 19 | - $result = value(function () use ($value) { |
|
| 20 | - $angka = ['', 'satu', 'dua', 'tiga', 'empat', 'lima', 'enam', 'tujuh', 'delapan', 'sembilan', 'sepuluh', 'sebelas']; |
|
| 19 | + $result = value(function() use ($value) { |
|
| 20 | + $angka = [ '', 'satu', 'dua', 'tiga', 'empat', 'lima', 'enam', 'tujuh', 'delapan', 'sembilan', 'sepuluh', 'sebelas' ]; |
|
| 21 | 21 | |
| 22 | 22 | $number = abs($value); |
| 23 | 23 | |
| 24 | 24 | switch (true) { |
| 25 | 25 | case $number < 12: |
| 26 | - return ' ' . $angka[$number]; |
|
| 26 | + return ' '.$angka[ $number ]; |
|
| 27 | 27 | |
| 28 | 28 | case $number < 20: |
| 29 | - return terbilang($number - 10) . ' belas'; |
|
| 29 | + return terbilang($number - 10).' belas'; |
|
| 30 | 30 | |
| 31 | 31 | case $number < 100: |
| 32 | - return terbilang($number / 10) . ' puluh ' . terbilang($number % 10); |
|
| 32 | + return terbilang($number / 10).' puluh '.terbilang($number % 10); |
|
| 33 | 33 | |
| 34 | 34 | case $number < 200: |
| 35 | - return 'seratus ' . terbilang($number - 100); |
|
| 35 | + return 'seratus '.terbilang($number - 100); |
|
| 36 | 36 | |
| 37 | 37 | case $number < 1000: |
| 38 | - return terbilang($number / 100) . ' ratus ' . terbilang($number % 100); |
|
| 38 | + return terbilang($number / 100).' ratus '.terbilang($number % 100); |
|
| 39 | 39 | |
| 40 | 40 | case $number < 2000: |
| 41 | - return 'seribu ' . terbilang($number - 1000); |
|
| 41 | + return 'seribu '.terbilang($number - 1000); |
|
| 42 | 42 | |
| 43 | 43 | case $number < 1000000: |
| 44 | - return terbilang($number / 1000) . ' ribu ' . terbilang($number % 1000); |
|
| 44 | + return terbilang($number / 1000).' ribu '.terbilang($number % 1000); |
|
| 45 | 45 | |
| 46 | 46 | case $number < 1000000000: |
| 47 | - return terbilang($number / 1000000) . ' juta ' . terbilang($number % 1000000); |
|
| 47 | + return terbilang($number / 1000000).' juta '.terbilang($number % 1000000); |
|
| 48 | 48 | |
| 49 | 49 | case $number < 1000000000000: |
| 50 | - return terbilang($number / 1000000000) . ' milyar ' . terbilang($number % 1000000000); |
|
| 50 | + return terbilang($number / 1000000000).' milyar '.terbilang($number % 1000000000); |
|
| 51 | 51 | |
| 52 | 52 | case $number < 1000000000000000: |
| 53 | - return terbilang($number / 1000000000000) . ' trilyun ' . terbilang($number % 1000000000000); |
|
| 53 | + return terbilang($number / 1000000000000).' trilyun '.terbilang($number % 1000000000000); |
|
| 54 | 54 | } |
| 55 | 55 | }); |
| 56 | 56 | |
| 57 | - return trim(($value < 0 ? 'minus ' : '') . $result); |
|
| 57 | + return trim(($value < 0 ? 'minus ' : '').$result); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -if (! function_exists('greeting')) { |
|
| 61 | +if (!function_exists('greeting')) { |
|
| 62 | 62 | /** |
| 63 | 63 | * Return specific greeting based on the current hour. |
| 64 | 64 | * |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -if (! function_exists('telegram_url')) { |
|
| 88 | +if (!function_exists('telegram_url')) { |
|
| 89 | 89 | /** |
| 90 | 90 | * Return base telegram bot API url. |
| 91 | 91 | * |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | -if (! function_exists('download_telegram_photo')) { |
|
| 101 | +if (!function_exists('download_telegram_photo')) { |
|
| 102 | 102 | /** |
| 103 | 103 | * Download telegram photo based on the given photo list. |
| 104 | 104 | * |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | function download_telegram_photo(array $photos, string $path) |
| 113 | 113 | { |
| 114 | - $photos = Arr::sort($photos, fn ($photo) => $photo['file_size']); |
|
| 114 | + $photos = Arr::sort($photos, fn($photo) => $photo[ 'file_size' ]); |
|
| 115 | 115 | |
| 116 | - $photoId = Arr::last($photos)['file_id']; |
|
| 116 | + $photoId = Arr::last($photos)[ 'file_id' ]; |
|
| 117 | 117 | |
| 118 | 118 | throw_unless($photoId, InvalidArgumentException::class, sprintf( |
| 119 | 119 | 'Telegram file_id is not found', $photoId |
@@ -132,15 +132,15 @@ discard block |
||
| 132 | 132 | env('TELEGRAM_TOKEN'), $photoFilePath |
| 133 | 133 | )); |
| 134 | 134 | |
| 135 | - $filename = Str::random() . '.' . pathinfo($photoFilePath, PATHINFO_EXTENSION); |
|
| 135 | + $filename = Str::random().'.'.pathinfo($photoFilePath, PATHINFO_EXTENSION); |
|
| 136 | 136 | |
| 137 | - Storage::put($path . '/' . $filename, $photo); |
|
| 137 | + Storage::put($path.'/'.$filename, $photo); |
|
| 138 | 138 | |
| 139 | 139 | return $filename; |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -if (! function_exists('google_map_url')) { |
|
| 143 | +if (!function_exists('google_map_url')) { |
|
| 144 | 144 | /** |
| 145 | 145 | * Return google map url based on the given latitude and longitude. |
| 146 | 146 | * |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | -if (! function_exists('format_rupiah')) { |
|
| 161 | +if (!function_exists('format_rupiah')) { |
|
| 162 | 162 | /** |
| 163 | 163 | * Return number in rupiah format. |
| 164 | 164 | * |
@@ -168,6 +168,6 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | function format_rupiah(float $value, string $prefix = null): string |
| 170 | 170 | { |
| 171 | - return $prefix . number_format($value, 0, ',', '.'); |
|
| 171 | + return $prefix.number_format($value, 0, ',', '.'); |
|
| 172 | 172 | } |
| 173 | 173 | } |
@@ -27,26 +27,26 @@ |
||
| 27 | 27 | public function datatable() |
| 28 | 28 | { |
| 29 | 29 | return DataTables::eloquent(Order::query()->with('user:id,fullname')) |
| 30 | - ->setTransformer(fn ($model) => OrderResource::make($model)->resolve()) |
|
| 31 | - ->orderColumn('customer_fullname', function ($query, $direction) { |
|
| 32 | - $query->with(['customer' => function ($query) use ($direction) { |
|
| 30 | + ->setTransformer(fn($model) => OrderResource::make($model)->resolve()) |
|
| 31 | + ->orderColumn('customer_fullname', function($query, $direction) { |
|
| 32 | + $query->with([ 'customer' => function($query) use ($direction) { |
|
| 33 | 33 | $query->orderBy('name', $direction); |
| 34 | - }]); |
|
| 34 | + } ]); |
|
| 35 | 35 | }) |
| 36 | - ->filterColumn('customer_fullname', function ($query, $keyword) { |
|
| 37 | - $query->with(['customer' => function ($query) use ($keyword) { |
|
| 36 | + ->filterColumn('customer_fullname', function($query, $keyword) { |
|
| 37 | + $query->with([ 'customer' => function($query) use ($keyword) { |
|
| 38 | 38 | $query->where('name', 'like', $keyword); |
| 39 | - }]); |
|
| 39 | + } ]); |
|
| 40 | 40 | }) |
| 41 | - ->orderColumn('status', function ($query, $direction) { |
|
| 42 | - $query->with(['latestStatus' => function ($query) use ($direction) { |
|
| 41 | + ->orderColumn('status', function($query, $direction) { |
|
| 42 | + $query->with([ 'latestStatus' => function($query) use ($direction) { |
|
| 43 | 43 | $query->orderBy('status', $direction); |
| 44 | - }]); |
|
| 44 | + } ]); |
|
| 45 | 45 | }) |
| 46 | - ->filterColumn('status', function ($query, $keyword) { |
|
| 47 | - $query->with(['latestStatus' => function ($query) use ($keyword) { |
|
| 46 | + ->filterColumn('status', function($query, $keyword) { |
|
| 47 | + $query->with([ 'latestStatus' => function($query) use ($keyword) { |
|
| 48 | 48 | $query->where('status', 'like', $keyword); |
| 49 | - }]); |
|
| 49 | + } ]); |
|
| 50 | 50 | }) |
| 51 | 51 | ->toJson(); |
| 52 | 52 | } |