A simple (straw) poll web application made with Laravel
https://poll.fuwafuwa.moe
選択できるのは25トピックまでです。
トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
22 行
390 B
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(); |
|
} |
|
}
|
|
|