12848091a2
Update to Laravel 9 and PHP 8+ Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Cron\Nightly;
|
|
|
|
use App\Contracts\Listener;
|
|
use App\Events\CronNightly;
|
|
use App\Models\Enums\ExpenseType;
|
|
use App\Services\Finance\RecurringFinanceService;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* Go through and apply any finances that are daily
|
|
*/
|
|
class ApplyExpenses extends Listener
|
|
{
|
|
private RecurringFinanceService $financeSvc;
|
|
|
|
/**
|
|
* ApplyExpenses constructor.
|
|
*
|
|
* @param RecurringFinanceService $financeSvc
|
|
*/
|
|
public function __construct(RecurringFinanceService $financeSvc)
|
|
{
|
|
$this->financeSvc = $financeSvc;
|
|
}
|
|
|
|
/**
|
|
* Apply all of the expenses for a day
|
|
*
|
|
* @param CronNightly $event
|
|
*
|
|
* @throws \UnexpectedValueException
|
|
* @throws \InvalidArgumentException
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
*/
|
|
public function handle(CronNightly $event): void
|
|
{
|
|
Log::info('Nightly: Applying daily expenses');
|
|
$this->financeSvc->processExpenses(ExpenseType::DAILY);
|
|
}
|
|
}
|