I am accessing a PayPalController through routes in routes/api.php but when I try to check if a user is authenticated, it returns:
local.ERROR: Auth guard [api] is not defined.
PayPalController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Srmklive\PayPal\Service\Paypal;
class PayPalController extends Controller
{
public function create(Request $request)
{
// both won't work
$id = Auth::id('api');
$id = auth('api')->user()->id;
}
}
routes/api.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::post('/paypal/order/create', [PayPalController::class, 'create']);