35 lines
709 B
PHP
35 lines
709 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Invitation;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
|
|
// General Housekeeping Job: Drop Approved and Completed Invites
|
|
class InviteLifecycleCleanup implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
Invitation::whereIn('status', ['approved', 'completed'])
|
|
->chunkById(100, function ($invites) {
|
|
foreach ($invites as $invite) {
|
|
$invite->delete();
|
|
}
|
|
});
|
|
}
|
|
}
|