This repository was archived by the owner on Aug 23, 2023. It is now read-only.
Description Hello, I created such a solution to run artisan commands according to context configs.
namespace App\Providers;
use Illuminate\Support\Str;
use Artificertech\FilamentMultiContext\ContextServiceProvider;
use Filament\FilamentServiceProvider;
class FilamentBlogServiceProvider extends ContextServiceProvider {
public static string $name = 'filament-blog';
public function boot(): void {
if ($this->app->runningInConsole()) {
$this->registerCommands();
}
parent::boot();
}
protected function registerCommands(): void {
$filamentCommands = (new FilamentServiceProvider($this->app))->getCommands();
$commands = [];
foreach ($filamentCommands as $class) {
/**
* @var \Illuminate\Console\Command $command
*/
$command = new $class;
$commandName = Str::replace(['filament:', 'filament-'], [static::$name . ':', static::$name . '-'], $command->getName());
$command->setName($commandName);
$command->setCode(function ($input, $output) use ($command) {
config(['filament' => config('filament-blog')]);
$command->handle($input, $output);
});
$commands[] = $command;
}
$this->commands($commands);
}
}
Reactions are currently unavailable
Hello, I created such a solution to run artisan commands according to context configs.