Files
nurafrinaalimi16 eac65986a6 pdf result
2024-04-29 16:56:53 +08:00

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();
}
}