<?php

namespace App\Listeners;

use Illuminate\Auth\Events\Registered;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use IvanSotelo\TwilioVerify\Contracts\MustVerifyPhoneContract;
use Illuminate\Support\Facades\Log;

class SendPhoneVerificationNotification
{

    /**
     * Handle the event.
     *
     * @param  \Illuminate\Auth\Events\Registered  $event
     * @return void
     */
    public function handle(Registered $event)
    {
        if ($event->user instanceof MustVerifyPhoneContract && is_null($event->user->phone_verified_at)) {
            $event->user->sendPhoneVerificationNotification();
        }
    }
}
