PHP code example of yaquawa / laravel-passport-binary-uuid-adapter

1. Go to this page and download the library: Download yaquawa/laravel-passport-binary-uuid-adapter 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/ */

    

yaquawa / laravel-passport-binary-uuid-adapter example snippets


namespace App\Exceptions;

use Exception;
use Illuminate\Support\Facades\Auth;
use Yaquawa\Laravel\PassportBinaryUuidAdapter\Helper;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
    /**
     * Get the default context variables for logging.
     *
     * @return array
     */
    protected function context()
    {
        try {
            $userId = Auth::id();

            if ($userId) {
                $userId = Helper::decodeUuid($userId);
            }

            return array_filter([
                'userId' => $userId,
                'email'  => Auth::user() ? Auth::user()->email : null,
            ]);
        } catch (Throwable $e) {
            return [];
        }
    }
}