28 lines
522 B
PHP
28 lines
522 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Result extends Model
|
|
{
|
|
protected $table = 'result';
|
|
protected $fillable = ['voter_id', 'nominee_id', 'position_id', 'election_id'];
|
|
// protected $appends = ['votes'];
|
|
|
|
|
|
|
|
function nominee() : BelongsTo {
|
|
return $this->belongsTo(Nominee::class);
|
|
}
|
|
|
|
public function votes($nominee_id)
|
|
{
|
|
return $this->where('nominee_id','=',$nominee_id)->count();
|
|
}
|
|
|
|
|
|
|
|
}
|