belongsTo(FaqTheme::class, 'theme_id'); } /** * get Utility * @return float|integer */ public function getUtilityAttribute() { $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 = $this->negative_vote / $this->positive_vote; $pourcent = ceil((1 - $ratio) * 100); } return $pourcent; } }