Skip to content
Snippets Groups Projects
Select Git revision
  • d810c62493fcbeb0b12df7037be4fa27755db523
  • main default protected
  • master
3 results

DelegationOneVote.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    DelegationOneVote.php 826 B
    <?php
    
    namespace App;
    
    use Illuminate\Database\Eloquent\Model;
    
    class DelegationOneVote extends Model
    {
        public $timestamps = false;
    
        protected $fillable = [
            'election_id',
            'voter_id',
            'vote_direct',
            'vote_delegation',
            'vote_weight',
            'vote_final'
        ];
    
        protected $appends = [
            //'final_delegation_one_vote'
        ];
    
        public function parentDelegationOneVote() {
            return $this->belongsTo(DelegationOneVote::class, 'vote_delegation', 'id');
        }
    
        public function getFinalDelegationOneVoteAttribute() {
            return $this->parentDelegationOneVote()->exists() ? $this->parentDelegationOneVote->vote_direct : $this->vote_direct;
        }
    
        public function election() {
            return $this->belongsTo(Election::class, 'election_id', 'id');
        }
    }