From e2d847e4ddd8f9e36ef271c794ea12f4c40d9f24 Mon Sep 17 00:00:00 2001 From: "dorgan@donaldorgan.com" Date: Mon, 23 Dec 2024 16:36:07 -0500 Subject: [PATCH 1/2] Update CommandService.php --- src/Http/Services/CommandService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Http/Services/CommandService.php b/src/Http/Services/CommandService.php index 2cd8fb7..b6bcb33 100644 --- a/src/Http/Services/CommandService.php +++ b/src/Http/Services/CommandService.php @@ -2,14 +2,14 @@ namespace RobersonFaria\DatabaseSchedule\Http\Services; -use App\Console\Kernel; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Collection; class CommandService { public function get(): Collection { - $commands = collect(app(Kernel::class)->all())->sortKeys(); + $commands = collect(app( Artisan::class)->all())->sortKeys(); $commandsKeys = $commands->keys()->toArray(); foreach (config('database-schedule.commands.exclude') as $exclude) { $commandsKeys = preg_grep("/^$exclude/", $commandsKeys, PREG_GREP_INVERT); From e51bd854ae547bf67343d47bc2c5f1577b06dbc3 Mon Sep 17 00:00:00 2001 From: "dorgan@donaldorgan.com" Date: Mon, 23 Dec 2024 16:52:19 -0500 Subject: [PATCH 2/2] Fixes for laravel 11 --- config/database-schedule.php | 11 ++++++++++- src/DatabaseSchedulingServiceProvider.php | 7 +++++-- src/Http/Services/CommandService.php | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/database-schedule.php b/config/database-schedule.php index c58e801..f39d2b3 100644 --- a/config/database-schedule.php +++ b/config/database-schedule.php @@ -90,7 +90,16 @@ 'queue:*', 'schedule:*', 'view:*', - 'phpunit:*' + 'phpunit:*', + 'install:*', + 'channel:*', + 'about', + 'docs', + 'model:*', + 'storage:unlink', + 'lang:publish', + '_complete', + 'completion', ] ], diff --git a/src/DatabaseSchedulingServiceProvider.php b/src/DatabaseSchedulingServiceProvider.php index 13c862f..0f84432 100644 --- a/src/DatabaseSchedulingServiceProvider.php +++ b/src/DatabaseSchedulingServiceProvider.php @@ -13,6 +13,7 @@ use RobersonFaria\DatabaseSchedule\Console\Commands\TestJobCommand; use RobersonFaria\DatabaseSchedule\Console\Commands\ScheduleClearCacheCommand; use RobersonFaria\DatabaseSchedule\Console\Scheduling\Schedule; +use Illuminate\Support\Facades\Schema; class DatabaseSchedulingServiceProvider extends DatabaseScheduleApplicationServiceProvider { @@ -63,8 +64,10 @@ public function boot() } $this->app->resolving(BaseSchedule::class, function ($schedule) { - $schedule = app(Schedule::class, ['schedule' => $schedule]); - return $schedule->execute(); + if (Schema::hasTable('schedules')) { + $schedule = app(Schedule::class, ['schedule' => $schedule]); + return $schedule->execute(); + } }); $this->commands([ diff --git a/src/Http/Services/CommandService.php b/src/Http/Services/CommandService.php index b6bcb33..c8839bc 100644 --- a/src/Http/Services/CommandService.php +++ b/src/Http/Services/CommandService.php @@ -9,7 +9,7 @@ class CommandService { public function get(): Collection { - $commands = collect(app( Artisan::class)->all())->sortKeys(); + $commands = collect(Artisan::all())->sortKeys(); $commandsKeys = $commands->keys()->toArray(); foreach (config('database-schedule.commands.exclude') as $exclude) { $commandsKeys = preg_grep("/^$exclude/", $commandsKeys, PREG_GREP_INVERT);