46 lines
909 B
PHP
46 lines
909 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PollResponse extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['poll_id', 'voter_id', 'voter_type', 'user_id', 'dedupe_key', 'ledger_sequence', 'submitted_at'];
|
|
|
|
protected $casts = [
|
|
'submitted_at' => 'datetime',
|
|
'ledger_sequence' => 'integer',
|
|
];
|
|
|
|
|
|
public function poll()
|
|
{
|
|
return $this->belongsTo(Poll::class);
|
|
}
|
|
|
|
/**
|
|
* The active profile that voted (user, organization, bank or admin).
|
|
*/
|
|
public function voter()
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
/**
|
|
* The user behind the voting profile.
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function answers()
|
|
{
|
|
return $this->hasMany(PollAnswer::class);
|
|
}
|
|
}
|