Add Cache for yearly remember
This commit is contained in:
parent
057002b8e8
commit
bf4cfdf7fd
|
@ -7,6 +7,7 @@ use App\Prevention\Data\PreventionData;
|
|||
use App\Prevention\Mails\YearlyMail;
|
||||
use App\Prevention\PreventionSettings;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
|
@ -40,7 +41,11 @@ class YearlyRememberAction
|
|||
continue;
|
||||
}
|
||||
|
||||
Mail::send($this->createMail($member, $preventions));
|
||||
Cache::remember(
|
||||
'prevention-' . $member->id,
|
||||
(int) now()->diffInSeconds(now()->addWeeks($settings->freshRememberInterval)),
|
||||
fn() => Mail::send($this->createMail($member, $preventions))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ class PreventionSettings extends LocalSettings
|
|||
public EditorData $formmail;
|
||||
public EditorData $yearlymail;
|
||||
public int $weeks;
|
||||
public int $freshRememberInterval;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
|
|
|
@ -8,5 +8,6 @@ return new class extends SettingsMigration
|
|||
{
|
||||
$this->migrator->add('prevention.yearlymail', ['time' => 1, 'blocks' => [], 'version' => '1.0']);
|
||||
$this->migrator->add('prevention.weeks', 8);
|
||||
$this->migrator->add('prevention.freshRememberInterval', 12);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue