Files
Caramel-CRM/app/Providers/EventServiceProvider.php
T

44 lines
1.2 KiB
PHP
Raw Normal View History

2025-11-11 21:20:15 +01:00
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Facades\Event;
2025-12-04 22:37:16 +01:00
use Illuminate\Support\Facades\Schema;
use Illuminate\Routing\Events\RouteMatched;
use App\Models\Setting;
use App\Listeners\ScheduleListener;
use App\Jobs\CheckInvoiceDueDatesJob;
2025-11-11 21:20:15 +01:00
class EventServiceProvider extends ServiceProvider
{
protected $listen = [];
2025-11-11 21:20:15 +01:00
/**
* Bootstrap services.
*/
public function boot(): void
{
parent::boot();
2025-12-04 22:37:16 +01:00
if (Schema::hasTable('settings')) {
$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();
2025-11-11 21:20:15 +01:00
}
}