Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

bytefury/crater

8213 stars
2 code files
View bytefury/crater on GitHub

app/Console/Commands/CheckInvoiceStatus.php

Open in GitHub
use Carbon\Carbon;
use Crater\Models\Invoice;
use Illuminate\Console\Command;
 
class CheckInvoiceStatus extends Command
{
protected $signature = 'check:invoices:status';
 
protected $description = 'Check invoices status.';
 
public function __construct()
{
parent::__construct();
}
 
public function handle()
{
$date = Carbon::now();
$invoices = Invoice::where('status', '<>', Invoice::STATUS_COMPLETED)->whereDate('due_date', '<', $date)->get();
 
foreach ($invoices as $invoice) {
$invoice->status = Invoice::STATUS_OVERDUE;
printf("Invoice %s is OVERDUE \n", $invoice->invoice_number);
$invoice->save();
}
}
}

app/Console/Kernel.php

Open in GitHub
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
class Kernel extends ConsoleKernel
{
//
protected function schedule(Schedule $schedule)
{
$schedule->command('check:invoices:status')
->daily();
//
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.