<?php

namespace App\Exports;

use App\Models\Student;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class AddNotExport implements FromView
{
    protected $class, $eval;
    public function __construct($class, $eval)
    {
        $this->class = $class;
        $this->eval = $eval;
    }

    
    public function view(): View
    {
        $data = Student::join('inscriptions', 'students.id', '=', 'inscriptions.student_id')
        ->select('inscriptions.id', 'students.first_name', 'students.last_name', 'students.matricule', 'students.sexe')
        ->where('inscriptions.classe_id', '=', $this->class)
        ->orderBy('students.first_name')
        ->orderBy('students.last_name')
        ->get();

        return view('exports.add_not_export', [
            'data' => $data,
            'class' => $this->class,
            'eval' => $this->eval
        ]);
    }
}
