HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/Http/Middleware/SanctumGuardConfigurator.php
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class SanctumGuardConfigurator
{
    /**
     * Changes the guard sanctum wil use when an api request comes in.
     * Will have a look at the third part of the url to determine which guard.
     *
     * Example: /api/v1/kms/account makes sure the kms guard will be used because the third segment is "kms".
     * Example: /api/v1/account makes sure the site guard will be used because the third segment is not "kms".
     *
     * Also see config/auth.php for the available guards. And notice their providers
     *
     * @param  Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $guard = 'site';
        if($request->segment(3) && strtolower($request->segment(3)) === 'kms') $guard = 'kms';
        config()->set('sanctum.guard', $guard);

        return $next($request);
    }
}