PHP code example of alive2212 / laravel-mobile-passport

1. Go to this page and download the library: Download alive2212/laravel-mobile-passport library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alive2212 / laravel-mobile-passport example snippets


    'providers' => [
        ...
        
        /*
         * Authentication service
         */
        Alive2212\LaravelMobilePassport\LaravelMobilePassportServiceProvider::class,
    ],

$app->register(Alive2212\LaravelMobilePassport\LaravelMobilePassportServiceProvider::class);

$app->router->group([
    'namespace' => 'Alive2212\LaravelMobilePassport\Http\Controllers',
], function ($router) {
    

public function boot()
{
    $this->registerPolicies();

    Passport::routes();

    LaravelMobilePassport::initPassportTokenCan();

    LaravelMobilePassportSingleton::$otpCallBack = function (
        Request $request,
        User $user,
        AliveMobilePassportDevice $device,
        $token
    ) {
        // dispatch send sms job here to send notification

    };
    
    
    LaravelMobilePassportSingleton::$otpConfirmCallBack = function (
        Request $request,
        User $user,
        PersonalAccessTokenResult $token,
        ResponseModel $response
    ) {
        // put something here like update user name with request fields
        
    };
    
}

    protected $fillable = [
        'name',
        'email',
        'password',
        'phone_number',
        'country_code',
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function roles()
    {
        return $this->belongsToMany(
            AliveMobilePassportRole::class,
            'alive_mobile_passport_role_user',
            'user_id',
            'role_id'
        );
    }

$ art passport:install

// add mobile passport routes
LaravelMobilePassport::routes(null,['middleware'=>'cors']);

$request['access_token'])

$ php artisan migrate

php artisan vendor:publish --tag laravel-mobile-passport.lang
php artisan vendor:publish --tag laravel-mobile-passport.config
php artisan vendor:publish --tag laravel-mobile-passport.migrations
php artisan vendor:publish --tag laravel-mobile-passport.models