pixelfed/app/Models/Poll.php

36 lines
589 B
PHP
Raw Permalink Normal View History

2021-08-05 02:29:21 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\HasSnowflakePrimary;
2021-08-05 02:29:21 +00:00
class Poll extends Model
{
use HasSnowflakePrimary, HasFactory;
2021-08-05 02:29:21 +00:00
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
protected $casts = [
'poll_options' => 'array',
'cached_tallies' => 'array',
'expires_at' => 'datetime'
];
2021-08-05 02:29:21 +00:00
public function votes()
{
return $this->hasMany(PollVote::class);
}
2021-08-05 02:29:21 +00:00
public function getTallies()
{
return $this->cached_tallies;
}
2021-08-05 02:29:21 +00:00
}