Two changes:
1. app/Http/Middleware/TeacherPortalAuthenticate.php:
- Added try-catch around Auth::guard('sanctum')->user() to match
the defensive pattern used by MultiAuth and
EnsurePrintRequestsAdminAccess middleware.
2. app/Providers/AppServiceProvider.php:
- Added Auth::resolved() callback to re-register the sanctum guard
driver as a safety net. This ensures the driver is available even
when a stale cached config lacks the auth.guards.sanctum entry,
or when SanctumServiceProvider::configureGuard() runs before
the AuthManager is ready to accept custom guard creators.