<?php

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

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

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

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

    public function getMoyen($id) {
        $dts = $this->srvs->getMoyenne($id, $this->cutting);
        return [
            'moyen' => $dts ? $dts->moyenne:'--',
            'rang' => $dts ? $dts->rang:'--',
            'ob' => $dts ? ($dts->moyenne != 'nc' ? appreciationGeneral($dts->moyenne):'--'):'--'
        ];
    }

    public function mount() {
        $this->levels = $this->srvs->getLevel($this->school, 4);
    }

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