- Need laravel livewire package
- The default template uses tailwind classes (customize it if you want)
-
install livewire
-
install doctrine/dbal
-
composer require lee-to/laravel-phone-auth
-
php artisan vendor:publish --provider="Leeto\PhoneAuth\Providers\PhoneAuthServiceProvider"
-
configure config/phone_auth.php
- Add PhoneVerification Trait to User Model
use PhoneVerification;
- Add phone cast to User Model
protected $casts = [
'phone' => PhoneCast::class
];
- Simple
@livewire('phone-verification')
- Without form wrap
@livewire('phone-verification', ['formWrap' => false])
- Register new or login if phone verified and exist
@livewire('phone-verification', ['loginAndRegister' => true])
\Leeto\PhoneAuth\Models\ConfirmedPhone::confirmed($phone, $user_id = null);
- stopEvents (bool) = turn off emitBefore, emitAfter
- customRedirectTo (bool|array) = redirect after success
- emptyCustomFields (bool) = disable custom fields
- customParams (array) = send custom properties to view
<livewire:phone-verification
:stopEvents="true"
:customRedirectTo="'/'"
:emptyCustomFields="true"
:customParams="['btn' => 'Login', 'title' => 'Login']"
:formWrap="false"
:loginAndRegister="true"
/>