PHP code example of yumemi-inc / google-iap-laravel

1. Go to this page and download the library: Download yumemi-inc/google-iap-laravel 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/ */

    

yumemi-inc / google-iap-laravel example snippets


    // app/Security/AppGoogleUserResolver.php (new)
   
   use Illuminate\Contracts\Auth\Authenticatable;
   use Illuminate\Contracts\Auth\UserProvider;
   use YumemiInc\GoogleIapLaravel\Claims;
   use YumemiInc\GoogleIapLaravel\GoogleUserResolver;
   
   class AppGoogleUserResolver implements GoogleUserResolver
   {
       public function provide(Claims $claims, UserProvider $userProvider): ?Authenticatable
       {
           return $userProvider->retrieveByCredentials([
               'google_user_id' => $claims->id(),
           ]);
       }
   }
   

    // app/Providers/AppServiceProvider.php
   
   use YumemiInc\GoogleIapLaravel\GoogleUserResolver;
   
   public function register(): void
   {
       $this->app->bind(GoogleUserProvider::class, AppGoogleUserProvider::class);
   }
   

    // config/auth.php

   'guards' => [
       'google-iap' => [
            'driver' => 'google-iap',
            'provider' => 'users',
        ],
   ]