Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Poll;
|
||||
use App\Polls\Ledger;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SealClosedPolls extends Command
|
||||
{
|
||||
protected $signature = 'polls:seal';
|
||||
|
||||
protected $description = 'Seal the ballot ledger of polls that have closed (status closed or past their closing time)';
|
||||
|
||||
public function handle(Ledger $ledger): int
|
||||
{
|
||||
$polls = Poll::whereNull('sealed_at')
|
||||
->where(fn ($query) => $query->where('status', Poll::STATUS_CLOSED)
|
||||
->orWhere(fn ($q) => $q->where('status', Poll::STATUS_OPEN)->where('closes_at', '<=', now())))
|
||||
->get();
|
||||
|
||||
foreach ($polls as $poll) {
|
||||
if ($entry = $ledger->seal($poll)) {
|
||||
$this->info("Sealed poll {$poll->id}: {$entry->hash}");
|
||||
}
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user