belongsTo(FaqTheme::class, 'theme_id'); } /** * Get utility attribute * * @return float */ public function getUtilityAttribute(): float { /** @var float */ $pourcent = 0; if ( $this->positive_vote !== null && $this->negative_vote !== null && $this->positive_vote >= $this->negative_vote && $this->positive_vote > 0 && $this->negative_vote > 0 ) { $ratio = \floatval($this->negative_vote / $this->positive_vote); $pourcent = \floatval(ceil((1 - $ratio) * 100)); } return $pourcent; } }