Skip to content

Commit

Permalink
Update helpers.php
Browse files Browse the repository at this point in the history
  • Loading branch information
crossplatformconsulting authored Oct 23, 2024
1 parent b23b926 commit 8ebcc8e
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,9 @@
/**
* @return string|null
*/
function getModelForGuard(string $guard)
function getModelForGuard(string $guard): ?string
{
// Get the guard configuration
$guardConfig = config("auth.guards.{$guard}");

// If the guard has a provider and the provider is defined
if (isset($guardConfig['provider'])) {
$provider = $guardConfig['provider'];

// Check if the provider uses LDAP
$providerConfig = config("auth.providers.{$provider}");

if (isset($providerConfig['driver']) && $providerConfig['driver'] === 'ldap') {
// Return the Eloquent model defined in the LDAP provider's database configuration
return $providerConfig['database']['model'] ?? null;
}

// Otherwise, return the standard Eloquent model
return config("auth.providers.{$provider}.model");
}

return null;
return Spatie\Permission\Guard::getModelForGuard($guard);
}

}
Expand Down

0 comments on commit 8ebcc8e

Please sign in to comment.