A simple (straw) poll web application made with Laravel https://poll.fuwafuwa.moe
您最多能選擇 25 個主題 主題必須以字母或數字為開頭,可包含連接號「-」且最長為 35 個字元。
 
 
 
 

22 行
390 B

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PollOption extends Model
{
public $timestamps = false;
protected $fillable = ['text'];
public function poll()
{
return $this->belongsTo('App\Poll');
}
public function getVoteCountAttribute()
{
return $this->poll->votes->where('poll_option_id', $this->id)->count();
}
}