pollthingy/app/PollOption.php

23 lines
390 B
PHP
Raw Normal View 히스토리

2018-10-16 03:23:19 +02:00
<?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');
}
2018-10-23 02:40:49 +02:00
public function getVoteCountAttribute()
{
return $this->poll->votes->where('poll_option_id', $this->id)->count();
}
2018-10-16 03:23:19 +02:00
}