ldc-legaulois/app/Models/FaqQuestions.php

25 lines
563 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class FaqQuestions extends Model
{
2020-09-28 09:52:22 +02:00
public function theme()
{
2021-04-12 10:01:48 +02:00
return $this->belongsTo(FaqThemes::class, 'faq_themes_id');
2020-09-28 09:52:22 +02:00
}
2021-03-20 14:38:15 +01:00
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;
}
}