Passed
Push — develop ( b4818b...dcecff )
by Septianata
16:14
created

ExchangeConversation::recordBranch()   B

Complexity

Conditions 7
Paths 2

Size

Total Lines 44
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
eloc 25
c 0
b 0
f 0
dl 0
loc 44
ccs 0
cts 26
cp 0
rs 8.5866
cc 7
nc 2
nop 3
crap 56
1
<?php
2
3
namespace App\Conversations;
4
5
use App\Enum\OrderStatus as EnumOrderStatus;
6
use App\Events\OrderCreated;
7
use App\Models\Branch;
8
use App\Models\Customer;
9
use App\Models\Denomination;
10
use App\Models\Item;
11
use App\Models\Order;
12
use App\Models\OrderStatus as ModelsOrderStatus;
13
use App\Models\User;
14
use BotMan\BotMan\Messages\Incoming\Answer;
15
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
16
use BotMan\BotMan\Messages\Outgoing\Question;
17
use BotMan\Drivers\Telegram\Extensions\Keyboard;
18
use BotMan\Drivers\Telegram\Extensions\KeyboardButton;
19
use Illuminate\Support\Collection;
20
use Illuminate\Support\Facades\Event;
21
use Illuminate\Support\Str;
22
23
class ExchangeConversation extends Conversation
24
{
25
    /**
26
     * Start the conversation.
27
     *
28
     * @return $this
29
     */
30
    public function run()
31
    {
32
        if (User::where('telegram_chat_id', $this->getUser()->getId())->count()) {
33
            return $this->say('conversations.exchange.alert-user');
34
        }
35
36
        if (Order::isMaximumOrderPerDayExceeded()) {
37
            return $this->sayRenderable('conversations.exchange.alert-exceeded-maximum-order-per-day');
38
        }
39
40
        return $this
41
            ->sayRenderable('conversations.exchange.index')
42
            ->verifyCustomer();
43
    }
44
45
    /**
46
     * Verify if the current customer has been registered or not.
47
     *
48
     * @return $this
49
     */
50
    protected function verifyCustomer()
51
    {
52
        if (!$customer = Customer::retrieveByBotManUser($this->getUser())) {
53
            $username = $this->getUser()->getUsername();
54
            $email = $this->getUserStorage('email');
55
56
            if (!$customer = Customer::retrieveByUsernameAndEmail(compact('username', 'email'))) {
57
                return $this
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->setPreviousConver...CustomerConversation()) targeting App\Conversations\Conver...on::startConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug Best Practice introduced by
The expression return $this->setPreviou...CustomerConversation()) returns the type void which is incompatible with the documented return type App\Conversations\ExchangeConversation.
Loading history...
58
                    ->setPreviousConversation($this)
59
                    ->sayRenderable('conversations.exchange.alert-registration-first')
60
                    ->startConversation(new RegisterCustomerConversation);
61
            }
62
        }
63
64
        return $this->displayCustomerData($customer);
65
    }
66
67
    /**
68
     * Reply with customer data.
69
     *
70
     * @param  \App\Models\Customer  $customer
71
     * @param  string|null  $validationErrorMessage
72
     * @return $this
73
     */
74
    protected function displayCustomerData(Customer $customer, string $validationErrorMessage = null)
75
    {
76
        $this->displayValidationErrorMessage($validationErrorMessage);
77
78
        if (!$this->getPreviousConversation() instanceof static) {
79
            $this->say('<em>Data anda sebelumnya sudah pernah terekam di database kami.</em>');
80
        }
81
82
        $this->destroyUserStorage(forceDestroy: true);
83
84
        $question = Question::create(view('conversations.exchange.confirm-customer_data', compact('customer'))->render())
0 ignored issues
show
Bug introduced by
It seems like view('conversations.exch...('customer'))->render() can also be of type array; however, parameter $text of BotMan\BotMan\Messages\Outgoing\Question::create() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

84
        $question = Question::create(/** @scrutinizer ignore-type */ view('conversations.exchange.confirm-customer_data', compact('customer'))->render())
Loading history...
85
            ->callbackId('exchange_confirm_customer_data')
86
            ->addButtons([
87
                Button::create(view('conversations.register-customer.reply-customer_data-yes')->render())->value('yes'),
0 ignored issues
show
Bug introduced by
It seems like view('conversations.regi...er_data-yes')->render() can also be of type array; however, parameter $text of BotMan\BotMan\Messages\O...ctions\Button::create() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

87
                Button::create(/** @scrutinizer ignore-type */ view('conversations.register-customer.reply-customer_data-yes')->render())->value('yes'),
Loading history...
88
                Button::create(view('conversations.register-customer.reply-customer_data-no')->render())->value('no'),
89
            ]);
90
91
        return $this->ask($question, next: function (Answer $answer) use ($customer) {
92
            if (!$answer->isInteractiveMessageReply()) {
93
                return;
94
            }
95
96
            if (!in_array($value = $answer->getValue(), ['yes', 'no'])) {
97
                return $this->displayCustomerData($customer, $this->fallbackMessage($answer->getText()));
98
            }
99
100
            if ($value === 'no') {
101
                $this->destroyUserStorage();
102
103
                return $this
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->setPreviousConver...CustomerConversation()) targeting App\Conversations\Conver...on::startConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
104
                    ->setPreviousConversation($this)
105
                    ->startConversation(new UpdateCustomerConversation);
106
            }
107
108
            return $this->recordOrder($customer);
109
        });
110
    }
111
112
    /**
113
     * Record customer order data.
114
     *
115
     * @param  \App\Models\Customer  $customer
116
     * @param  string|null  $validationErrorMessage
117
     * @return $this
118
     */
119
    protected function recordOrder(Customer $customer, string $validationErrorMessage = null)
120
    {
121
        $this->displayValidationErrorMessage($validationErrorMessage);
122
123
        $denominations = Denomination::all('id', 'name', 'value');
124
        $keyboard = Keyboard::create(Keyboard::TYPE_INLINE)->resizeKeyboard();
125
126
        foreach ($denominations as $denomination) {
127
            $keyboard->addRow(
128
                KeyboardButton::create(
129
                    view('conversations.exchange.reply-denomination', compact('denomination'))->render()
130
                )->callbackData($denomination->getKey())
131
            );
132
        }
133
134
        $response = $this->reply(
135
            $question = view('conversations.exchange.alert-denomination')->render(),
0 ignored issues
show
Bug introduced by
It seems like $question = view('conver...enomination')->render() can also be of type array; however, parameter $message of App\Conversations\Conversation::reply() does only seem to accept BotMan\BotMan\Messages\O...utgoing\Question|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

135
            /** @scrutinizer ignore-type */ $question = view('conversations.exchange.alert-denomination')->render(),
Loading history...
136
            $additionalParameters = $keyboard->toArray()
137
        );
138
139
        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response, $customer, $denominations) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getBot()->storeCo... $additionalParameters) targeting BotMan\BotMan\BotMan::storeConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
140
            if (!$answer->isInteractiveMessageReply()) {
141
                return;
142
            }
143
144
            $this->deleteTelegramMessageFromResponse($response);
145
146
            /** @var \App\Models\Denomination|null $denomination */
147
            if (!$denominations->contains($answer->getValue()) || !$denomination = Denomination::find($answer->getValue())) {
148
                return $this->recordOrder($customer, $this->fallbackMessage($answer->getText()));
149
            }
150
151
            /** @var \App\Models\Order $order */
152
            $order = Order::findOrCreateFromCode($this->getUserStorage('order_code'), $customer, function (Order $order) {
153
                $this->setUserStorage(['order_code' => $order->code]);
154
            });
155
156
            if ($order->isMaximumTotalOrderExceeded()) {
157
                return $this->confirmOrder($order, 'Maaf, total pesanan anda sudah mencapai batas maksimum');
158
            }
159
160
            /**
161
             * If there is an order's item that has same denomination with the selected one,
162
             * then it will be deleted first before customer continue to record item.
163
             */
164
            if ($item = $order->items()->whereHasDenomination($denomination)->first('id')) {
165
                $item->delete();
166
            }
167
168
            /**
169
             * If customer want to add another item, we assume that
170
             * the customer already choose the branch.
171
             */
172
            if ($order->branch && $order->has('items')->exists()) {
173
                return $this->recordItem($order, $denomination);
174
            }
175
176
            return $this->recordBranch($order, $denomination);
177
        }, question: $question, additionalParameters: $additionalParameters);
178
    }
179
180
    /**
181
     * Record customer branch data.
182
     *
183
     * @param  \App\Models\Order  $order
184
     * @param  \App\Models\Denomination  $denomination
185
     * @param  string|null  $validationErrorMessage
186
     * @return $this
187
     */
188
    protected function recordBranch(Order $order, Denomination $denomination, string $validationErrorMessage = null)
189
    {
190
        $this->displayValidationErrorMessage($validationErrorMessage);
191
192
        $branches = Branch::all('id', 'name');
193
        $keyboard = Keyboard::create(Keyboard::TYPE_INLINE)->resizeKeyboard();
194
195
        foreach ($branches as $branch) {
196
            $keyboard->addRow(
197
                KeyboardButton::create(
198
                    view('conversations.exchange.reply-branch', compact('branch'))->render()
199
                )->callbackData($branch->getKey())
200
            );
201
        }
202
203
        $keyboard->addRow(
204
            KeyboardButton::create(
205
                view('conversations.exchange.reply-branch-empty')->render()
206
            )->callbackData('branch_empty')
207
        );
208
209
        $response = $this->reply(
210
            $question = view('conversations.exchange.alert-branch')->render(),
0 ignored issues
show
Bug introduced by
It seems like $question = view('conver...lert-branch')->render() can also be of type array; however, parameter $message of App\Conversations\Conversation::reply() does only seem to accept BotMan\BotMan\Messages\O...utgoing\Question|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

210
            /** @scrutinizer ignore-type */ $question = view('conversations.exchange.alert-branch')->render(),
Loading history...
211
            $additionalParameters = $keyboard->toArray()
212
        );
213
214
        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response, $order, $denomination, $branches) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getBot()->storeCo... $additionalParameters) targeting BotMan\BotMan\BotMan::storeConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
215
            if (!$answer->isInteractiveMessageReply()) {
216
                return;
217
            }
218
219
            $this->deleteTelegramMessageFromResponse($response);
220
221
            /** @var \App\Models\Branch|null $branch */
222
            if ((!$branches->contains($answer->getValue()) && $answer->getValue() !== 'branch_empty') || !$branch = Branch::find($answer->getValue())) {
223
                return $this->recordBranch($order, $denomination, $this->fallbackMessage($answer->getText()));
224
            }
225
226
            if ($answer->getValue() !== 'branch_empty') {
227
                $order->setBranchRelationValue($branch)->save();
228
            }
229
230
            return $this->recordItem($order, $denomination);
231
        }, question: $question, additionalParameters: $additionalParameters);
232
    }
233
234
    /**
235
     * Record customer item data.
236
     *
237
     * @param  \App\Models\Order  $order
238
     * @param  \App\Models\Denomination  $denomination
239
     * @param  string|null  $validationErrorMessage
240
     * @return $this
241
     */
242
    protected function recordItem(Order $order, Denomination $denomination, string $validationErrorMessage = null)
243
    {
244
        $this->displayValidationErrorMessage($validationErrorMessage);
245
246
        $keyboard = Keyboard::create(Keyboard::TYPE_INLINE)->resizeKeyboard();
247
        $unit = Str::lower($denomination->type->label);
248
249
        collect($denomination->range_order_bundle)->chunk(3)->map(function (Collection $quantities) use ($keyboard, $unit) {
0 ignored issues
show
Unused Code introduced by
The import $unit is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
250
            $keyboard->addRow(...$quantities->map(fn ($quantity) => KeyboardButton::create(
251
                view('conversations.exchange.reply-bundle_quantity-quantity', compact('quantity'))->render()
252
            )->callbackData($quantity))->toArray());
253
        });
254
255
        $keyboard->addRow(
256
            KeyboardButton::create(
257
                view('conversations.exchange.reply-bundle_quantity-custom')->render()
258
            )->callbackData('bundle_quantity_custom')
259
        );
260
261
        $response = $this->reply(
262
            $question = view('conversations.exchange.ask-bundle_quantity', compact('denomination'))->render(),
0 ignored issues
show
Bug introduced by
It seems like $question = view('conver...nomination'))->render() can also be of type array; however, parameter $message of App\Conversations\Conversation::reply() does only seem to accept BotMan\BotMan\Messages\O...utgoing\Question|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

262
            /** @scrutinizer ignore-type */ $question = view('conversations.exchange.ask-bundle_quantity', compact('denomination'))->render(),
Loading history...
263
            $additionalParameters = $keyboard->toArray()
264
        );
265
266
        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response, $order, $denomination) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getBot()->storeCo... $additionalParameters) targeting BotMan\BotMan\BotMan::storeConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
267
            $this->deleteTelegramMessageFromResponse($response);
268
269
            if ($answer->getValue() === 'bundle_quantity_custom') {
270
                $this->deleteTelegramMessageFromResponse($response);
271
272
                $response2 = $this->reply(
273
                    $question2 = view('conversations.exchange.ask-bundle_quantity-custom', compact('denomination'))->render(),
0 ignored issues
show
Bug introduced by
It seems like $question2 = view('conve...nomination'))->render() can also be of type array; however, parameter $message of App\Conversations\Conversation::reply() does only seem to accept BotMan\BotMan\Messages\O...utgoing\Question|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

273
                    /** @scrutinizer ignore-type */ $question2 = view('conversations.exchange.ask-bundle_quantity-custom', compact('denomination'))->render(),
Loading history...
274
                    $additionalParameters2 = Keyboard::create(Keyboard::TYPE_KEYBOARD)
275
                        ->resizeKeyboard()
276
                        ->oneTimeKeyboard()
277
                        ->addRow(KeyboardButton::create(
278
                            $backToDenominationOption = trim(view('components.conversations.back', ['text' => 'opsi nominal'])->render())
0 ignored issues
show
Bug introduced by
It seems like view('components.convers...si nominal'))->render() can also be of type array; however, parameter $string of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

278
                            $backToDenominationOption = trim(/** @scrutinizer ignore-type */ view('components.conversations.back', ['text' => 'opsi nominal'])->render())
Loading history...
279
                        )->callbackData('back_to_denomination_option'))->toArray()
280
                );
281
282
                return $this->getBot()->storeConversation($this, function (Answer $answer) use ($response2, $order, $denomination, $backToDenominationOption) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getBot()->storeCo...$additionalParameters2) targeting BotMan\BotMan\BotMan::storeConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
283
                    $this->deleteTelegramMessageFromResponse($response2);
284
285
                    if ($answer->getText() === $backToDenominationOption) {
286
                        return $this->recordItem($order, $denomination);
287
                    }
288
289
                    return $this->createItem($order, $denomination, $answer->getText());
0 ignored issues
show
Bug introduced by
$answer->getText() of type string is incompatible with the type integer expected by parameter $value of App\Conversations\Exchan...versation::createItem(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

289
                    return $this->createItem($order, $denomination, /** @scrutinizer ignore-type */ $answer->getText());
Loading history...
290
                }, $question2, $additionalParameters2);
0 ignored issues
show
Bug introduced by
It seems like $question2 can also be of type array; however, parameter $question of BotMan\BotMan\BotMan::storeConversation() does only seem to accept BotMan\BotMan\Messages\Outgoing\Question|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

290
                }, /** @scrutinizer ignore-type */ $question2, $additionalParameters2);
Loading history...
291
            }
292
293
            return $this->createItem($order, $denomination, $answer->getValue());
0 ignored issues
show
Bug introduced by
$answer->getValue() of type string is incompatible with the type integer expected by parameter $value of App\Conversations\Exchan...versation::createItem(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

293
            return $this->createItem($order, $denomination, /** @scrutinizer ignore-type */ $answer->getValue());
Loading history...
294
        }, question: $question, additionalParameters: $additionalParameters);
295
    }
296
297
    /**
298
     * Create an item data based on the given order, denomination, and value.
299
     *
300
     * @param  \App\Models\Order  $order
301
     * @param  \App\Models\Denomination  $denomination
302
     * @param  int  $value
303
     * @return $this
304
     */
305
    protected function createItem(Order $order, Denomination $denomination, int $value)
306
    {
307
        if (!$denomination->isBetweenOrderBundle($value)) {
308
            return $this->recordItem($order, $denomination, trans('validation.between.numeric', [
0 ignored issues
show
Bug introduced by
It seems like trans('validation.betwee...>maximum_order_bundle)) can also be of type array and array; however, parameter $validationErrorMessage of App\Conversations\Exchan...versation::recordItem() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

308
            return $this->recordItem($order, $denomination, /** @scrutinizer ignore-type */ trans('validation.between.numeric', [
Loading history...
309
                'attribute' => trans('Quantity Per Bundle'),
310
                'min' => $denomination->minimum_order_bundle,
311
                'max' => $denomination->maximum_order_bundle,
312
            ]));
313
        }
314
315
        $item = new Item([
316
            'quantity_per_bundle' => $denomination->quantity_per_bundle,
317
            'bundle_quantity' => $value,
318
        ]);
319
320
        $item->setDenominationRelationValue($denomination);
321
322
        $order->items()->save($item);
323
324
        return $this->confirmOrder($order);
325
    }
326
327
    /**
328
     * Confirm customer order data.
329
     *
330
     * @param  \App\Models\Order  $order
331
     * @param  string|null  $validationErrorMessage
332
     * @return $this
333
     */
334
    protected function confirmOrder(Order $order, string $validationErrorMessage = null)
335
    {
336
        $this->displayValidationErrorMessage($validationErrorMessage);
337
338
        $keyboard = Keyboard::create(Keyboard::TYPE_INLINE)->resizeKeyboard()
339
            ->addRow(KeyboardButton::create(view('conversations.exchange.reply-order-yes')->render())
340
                ->callbackData('update_order_status')
341
            )->addRow(KeyboardButton::create(view('conversations.exchange.reply-order-no-update-item')->render())
342
                ->callbackData('update_item')
343
            )->addRow(KeyboardButton::create(view('conversations.exchange.reply-order-no-recreate-item')->render())
344
                ->callbackData('recreate_item')
345
            );
346
347
        $order->load('customer:id,fullname', 'items.denomination');
348
349
        $responseConfirmOrder = $this->reply(view('conversations.exchange.confirm-order', compact('order'))->render());
0 ignored issues
show
Bug introduced by
It seems like view('conversations.exch...act('order'))->render() can also be of type array; however, parameter $message of App\Conversations\Conversation::reply() does only seem to accept BotMan\BotMan\Messages\O...utgoing\Question|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

349
        $responseConfirmOrder = $this->reply(/** @scrutinizer ignore-type */ view('conversations.exchange.confirm-order', compact('order'))->render());
Loading history...
350
351
        $response = $this->reply(
352
            $question = view('conversations.exchange.ask-order')->render(),
353
            $additionalParameters = $keyboard->toArray()
354
        );
355
356
        return $this->getBot()->storeConversation($this, next: function (Answer $answer) use ($response, $responseConfirmOrder, $order) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getBot()->storeCo... $additionalParameters) targeting BotMan\BotMan\BotMan::storeConversation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
357
            $this->deleteTelegramMessageFromResponse($response);
358
359
            switch ($answer->getValue()) {
360
                case 'update_order_status':
361
                    $order->statuses()->save(ModelsOrderStatus::make([
0 ignored issues
show
Bug introduced by
It seems like App\Models\OrderStatus::...ustomerRelationValue()) can also be of type Illuminate\Database\Eloquent\Builder; however, parameter $model of Illuminate\Database\Eloq...ns\HasOneOrMany::save() does only seem to accept Illuminate\Database\Eloquent\Model, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

361
                    $order->statuses()->save(/** @scrutinizer ignore-type */ ModelsOrderStatus::make([
Loading history...
362
                        'status' => EnumOrderStatus::on_progress(),
363
                    ])->setIssuerableRelationValue($order->getCustomerRelationValue()));
364
365
                    Event::dispatch(new OrderCreated($order));
366
367
                    return $this->sayRenderable('conversations.exchange.alert-update_order_status', compact('order'));
368
369
                case 'update_item':
370
                case 'recreate_item':
371
                    $this->deleteTelegramMessageFromResponse($responseConfirmOrder);
372
373
                    if ($answer->getValue() === 'recreate_item') {
374
                        $order->items->map->delete();
375
                    }
376
377
                    return $this->recordOrder($order->getCustomerRelationValue());
378
379
                default:
380
                    return $this->confirmOrder($order, $this->fallbackMessage($answer->getText()));
381
            }
382
        }, question: $question, additionalParameters: $additionalParameters);
383
    }
384
}
385