ldc-legaulois/app/Models/FaqQuestions.php
2022-02-10 16:14:58 +01:00

24 lines
566 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class FaqQuestions extends Model
{
public function theme()
{
return $this->belongsTo(FaqThemes::class, 'faq_themes_id');
}
public function getUtilityAttribute()
{
$pourcent = 0;
if ($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;
}
}