mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Crater\Console;
|
|
|
|
use Crater\Models\RecurringInvoice;
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
class Kernel extends ConsoleKernel
|
|
{
|
|
/**
|
|
* The Artisan commands provided by your application.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $commands = [
|
|
Commands\ResetApp::class,
|
|
Commands\UpdateCommand::class,
|
|
Commands\CreateTemplateCommand::class
|
|
];
|
|
|
|
/**
|
|
* Define the application's command schedule.
|
|
*
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
* @return void
|
|
*/
|
|
protected function schedule(Schedule $schedule)
|
|
{
|
|
if (\Storage::disk('local')->has('database_created')) {
|
|
$schedule->command('check:invoices:status')
|
|
->daily();
|
|
|
|
$schedule->command('check:estimates:status')
|
|
->daily();
|
|
|
|
$recurringInvoices = RecurringInvoice::where('status', 'ACTIVE')->get();
|
|
foreach ($recurringInvoices as $recurringInvoice) {
|
|
$schedule->call(function () use ($recurringInvoice) {
|
|
$recurringInvoice->generateInvoice();
|
|
})->cron($recurringInvoice->frequency);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the Closure based commands for the application.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function commands()
|
|
{
|
|
$this->load(__DIR__.'/Commands');
|
|
require base_path('routes/console.php');
|
|
}
|
|
}
|