Skip to content

Commit

Permalink
Detect App\Model\User from skeleton if available (#288)
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Dec 29, 2024
1 parent 7fdabdc commit 11635f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/Bootstrap/LoadConfigurationWithWorkbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Orchestra\Testbench\Workbench\Workbench;
use Symfony\Component\Finder\Finder;

use function Orchestra\Testbench\join_paths;
use function Orchestra\Testbench\workbench_path;

/**
Expand Down Expand Up @@ -41,10 +40,6 @@ public function bootstrap(Application $app): void

$userModel = Workbench::applicationUserModel();

if (\is_null($userModel) && is_file($app->basePath(join_paths('Models', 'User.php')))) {
$userModel = 'App\Models\User';
}

if (! \is_null($userModel) && is_a($userModel, Authenticatable::class, true)) {
$app->make('config')->set('auth.providers.users.model', $userModel);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Workbench/Workbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Finder\Finder;

use function Orchestra\Testbench\after_resolving;
use function Orchestra\Testbench\join_paths;
use function Orchestra\Testbench\package_path;
use function Orchestra\Testbench\workbench_path;

Expand Down Expand Up @@ -310,6 +311,7 @@ public static function applicationUserModel(): ?string
static::$cachedUserModel = match (true) {
Env::has('AUTH_MODEL') => Env::get('AUTH_MODEL'),
is_file(workbench_path('app', 'Models', 'User.php')) => \sprintf('%sModels\User', static::detectNamespace('app')),
is_file(base_path(join_paths('Models', 'User.php'))) => 'App\Models\User',
default => false,
};
}
Expand Down

0 comments on commit 11635f9

Please sign in to comment.