Passed
Push — develop ( 62f833...95decf )
by Septianata
11:22
created

LogoutConversation::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace App\Conversations;
4
5
use App\Models\User;
6
use App\Support\Auth\MultipleIdentifier;
7
8
class LogoutConversation extends Conversation
9
{
10
    use MultipleIdentifier;
11
12
    /**
13
     * Start the conversation.
14
     *
15
     * @return $this
16
     */
17
    public function run()
18
    {
19
        /** @var \App\Models\User|null $user */
20
        if ($user = User::firstWhere('telegram_chat_id', $this->getUser()->getId())) {
21
            $user->update(['telegram_chat_id' => null]);
22
23
            return $this->sayRenderable('conversations.logout.alert-success');
24
        }
25
26
        return $this->sayRenderable('conversations.logout.alert-unauthenticated');
27
    }
28
}
29