<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alhaji-aki / laravel-phone-number-verification example snippets
namespace App\Models;
use AlhajiAki\OtpToken\Contracts\CanSendOtpToken as CanSendOtpTokenContract;
use AlhajiAki\OtpToken\Traits\CanSendOtpToken;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable implements CanSendOtpTokenContract
{
use Notifiable, CanSendOtpToken;
}
namespace App\Models;
use AlhajiAki\OtpToken\Contracts\CanSendOtpToken as CanSendOtpTokenContract;
use AlhajiAki\OtpToken\Traits\CanSendOtpToken;
use AlhajiAki\PhoneNumberVerification\Contracts\MustVerifyPhoneNumber as MustVerifyPhoneNumberContract;
use AlhajiAki\PhoneNumberVerification\Traits\MustVerifyPhoneNumber;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable implements CanSendOtpTokenContract, MustVerifyPhoneNumberContract
{
use Notifiable, CanSendOtpToken, MustVerifyPhoneNumber;
}
namespace App\Models;
use AlhajiAki\OtpToken\Contracts\CanSendOtpToken as CanSendOtpTokenContract;
use AlhajiAki\OtpToken\Traits\CanSendOtpToken;
use AlhajiAki\PhoneNumberVerification\Contracts\MustVerifyPhoneNumber as MustVerifyPhoneNumberContract;
use AlhajiAki\PhoneNumberVerification\Traits\MustVerifyPhoneNumber;
use App\Notifications\Auth\VerifyPhoneNumber;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable implements CanSendOtpTokenContract, MustVerifyPhoneNumberContract
{
use Notifiable, CanSendOtpToken, MustVerifyPhoneNumber;
public function phoneNumberAttribute(): string
{
return 'phone_number';
}
public function phoneNumberVerificationAttribute(): string
{
return 'phone_number_verified_at';
}
public function sendPhoneNumberVerificationNotification(string $token): void
{
$this->notify(new VerifyPhoneNumber($token));
}
}
/**
* The event listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
...
Registered::class => [
SendPhoneNumberVerificationNotification::class,
],
...
];