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,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* One entry in a poll's append-only ballot ledger. Holds no voter identity.
|
||||
* Entries are only ever inserted, through App\Polls\Ledger.
|
||||
*/
|
||||
class PollLedgerEntry extends Model
|
||||
{
|
||||
public const CAST = 'cast';
|
||||
public const CHANGE = 'change';
|
||||
public const WITHDRAW = 'withdraw';
|
||||
public const SEAL = 'seal';
|
||||
|
||||
protected $table = 'poll_ledger';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'poll_id', 'sequence', 'format_version', 'entry_type', 'fingerprint', 'refers_to_sequence',
|
||||
'payload', 'recorded_at', 'previous_hash', 'hash',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'sequence' => 'integer',
|
||||
'format_version' => 'integer',
|
||||
'refers_to_sequence' => 'integer',
|
||||
'payload' => 'array',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::updating(fn () => throw new LogicException('Poll ledger entries cannot be changed.'));
|
||||
static::deleting(fn () => throw new LogicException('Poll ledger entries cannot be deleted.'));
|
||||
}
|
||||
|
||||
public function poll()
|
||||
{
|
||||
return $this->belongsTo(Poll::class);
|
||||
}
|
||||
|
||||
public function isBallot(): bool
|
||||
{
|
||||
return in_array($this->entry_type, [self::CAST, self::CHANGE], true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user