Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alias for deferred provider #112

Merged
merged 4 commits into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/IdeHelperServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@

class IdeHelperServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* @var string
*/
const ModelsCommandAlias = __NAMESPACE__ . '\\' . ModelsCommand::class;

public function boot(): void
{
// Laravel only allows a single deferred service provider to claim
// responsibility for a given class, interface, or service in the
// provides() method. To ensure this provider is properly loaded
// when running the ModelsCommand we bind an alias and use that instead.
$this->app->alias(ModelsCommand::class, static::ModelsCommandAlias);
}

public function register(): void
{
/** @var \Illuminate\Config\Repository $config */
Expand All @@ -24,12 +38,12 @@ public function register(): void
}

/**
* @return list<class-string<\Illuminate\Console\Command>>
* @return list<string>
*/
public function provides(): array
{
return [
ModelsCommand::class,
static::ModelsCommandAlias,
];
}
}