Skip to content

Commit

Permalink
specify commands that will not be available on web interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
systemsolutionweb committed Apr 25, 2023
1 parent 6bf50f1 commit 75ff7ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Package.php
Expand Up @@ -27,6 +27,8 @@ class Package

public array $commands = [];

public array $consoleCommands = [];

public array $viewComponents = [];

public array $sharedViewData = [];
Expand Down Expand Up @@ -70,7 +72,7 @@ public function hasInstallCommand($callable): static

$callable($installCommand);

$this->commands[] = $installCommand;
$this->consoleCommands[] = $installCommand;

return $this;
}
Expand Down Expand Up @@ -177,6 +179,20 @@ public function hasCommands(...$commandClassNames): static
return $this;
}

public function hasConsoleCommand(string $commandClassName): static
{
$this->consoleCommands[] = $commandClassName;

return $this;
}

public function hasConsoleCommands(...$commandClassNames): static
{
$this->consoleCommands = array_merge($this->consoleCommands, collect($commandClassNames)->flatten()->toArray());

return $this;
}

public function hasRoute(string $routeFileName): static
{
$this->routeFileNames[] = $routeFileName;
Expand Down
4 changes: 4 additions & 0 deletions src/PackageServiceProvider.php
Expand Up @@ -104,6 +104,10 @@ public function boot()
$this->commands($this->package->commands);
}

if (! empty($this->package->consoleCommands) && $this->app->runningInConsole()) {
$this->commands($this->package->consoleCommands);
}

if ($this->package->hasTranslations) {
$this->loadTranslationsFrom(
$this->package->basePath('/../resources/lang/'),
Expand Down

0 comments on commit 75ff7ef

Please sign in to comment.