Impment webcron and internal scheduling methods and change settings to a key value store

This commit is contained in:
2025-12-03 14:23:03 +01:00
parent e37a14993d
commit 53acdb40b7
12 changed files with 222 additions and 90 deletions
+24 -5
View File
@@ -3,14 +3,17 @@
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Facades\Event;
use Illuminate\Routing\Events\RouteMatched;
use App\Models\Setting;
use App\Listeners\ScheduleListener;
use App\Jobs\CheckInvoiceDueDatesJob;
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
'Illuminate\Routing\Events\RouteMatched' => [
\App\Listeners\CheckInvoiceDueDatesListener::class,
],
];
protected $listen = [];
/**
* Bootstrap services.
@@ -18,5 +21,21 @@ class EventServiceProvider extends ServiceProvider
public function boot(): void
{
parent::boot();
$method = Setting::where('key', 'app.schedule_method')->value('value') ?? 'internal';
if ($method === 'internal') {
Event::listen(RouteMatched::class, [ScheduleListener::class, 'handle']);
}
// TODO: read where to put these
// it seems to work here, but where is the apropriate place?
// Kernel::schedule did not work
Schedule::command('caldav:sync')
->everyMinute()
->withoutOverlapping();
Schedule::job(new CheckInvoiceDueDatesJob())
->daily()
->withoutOverlapping();
}
}