Lae/app/Jobs/SendThisMonthModuleEarnings.php

57 lines
1.2 KiB
PHP
Raw Normal View History

2022-10-31 11:50:32 +00:00
<?php
namespace App\Jobs;
2022-11-06 11:28:22 +00:00
use App\Models\Module;
2022-10-31 11:50:32 +00:00
use App\Notifications\ModuleEarnings;
use Illuminate\Support\Facades\Cache;
class SendThisMonthModuleEarnings extends Job
{
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
$default = [
'balance' => 0,
'drops' => 0,
];
$rate = config('drops.module_rate');
Module::chunk(
100,
function ($modules) use ($default, $rate) {
foreach ($modules as $module) {
$data = [
'transactions' => [
'this_month' => Cache::get('this_month_balance_and_drops_' . $module->id, $default),
'last_month' => Cache::get('last_month_balance_and_drops_' . $module->id, $default),
],
'rate' => $rate,
];
2022-10-31 12:03:20 +00:00
(new ModuleEarnings($module))
2022-10-31 11:50:32 +00:00
->toGroup($data);
}
}
);
}
}