<?php

use App\Services\Chapter1Service;
use Livewire\Component;

return new class extends Component
{
    public $dts;
    public $class;
    public $school;
    public $cutting;
    protected $srvs;

    public function boot(Chapter1Service $srvs) {
        $this->srvs = $srvs;
    }

    public function getResultat($id) {
        return $this->srvs->resultat($id, $this->cutting);
    }

    public function mount() {
        $this->dts = $this->srvs->getClasse($this->class, $this->school, $this->cutting);
    }

    public function getVals($val) {
        return $val < 10 ? '0'.$val:$val;
    }

    public function getNbre($tls1, $tls2, $tls3) {
        $tls = $tls1 + $tls2 + $tls3;
        return $this->getVals($tls);
    }

    public function getPrtge($tls1, $tls2, $tls3) {
        $tls = null;
        if($tls1) {
            $tls = round(($tls1 / ($tls1 + $tls2 + $tls3)) * 100, 2);
        }
        return $tls ? $tls.'%':'00';
    }

    protected function view($data = [])
    {
        return app('view')->file('C:\Users\EDUCAS\Desktop\App\V4_001\storage\framework/views/livewire/views/083c10bb.blade.php', $data);
    }
};
