NotifyNewUser::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
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 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Listeners\Notify;
4
5
use Illuminate\Support\Str;
6
use App\Events\Admin\NewUserCreated;
7
use App\Models\UserInitialize;
8
use App\Notifications\SendWelcomeEmail;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use Illuminate\Queue\InteractsWithQueue;
11
use Illuminate\Support\Facades\Notification;
12
13
class NotifyNewUser implements ShouldQueue
14
{
15
    /**
16
     * Handle the event
17
     */
18
    public function handle(NewUserCreated $event)
19
    {
20
        //  Create a User Initialization Link
21
        UserInitialize::create([
22
            'username' => $event->user->username,
23
            'token'    => $token = Str::uuid(),
24
        ]);
25
26
        Notification::send($event->user, new SendWelcomeEmail($token));
27
    }
28
}
29