<br />
<b>Warning</b>:  Undefined variable $auth in <b>/home/pevo0181/public_html/pia-soft.com/cleania/routes/index.php</b> on line <b>542</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type null in <b>/home/pevo0181/public_html/pia-soft.com/cleania/routes/index.php</b> on line <b>542</b><br />
<?php

namespace App\Exports;

use Carbon\Carbon;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithColumnWidths;


class StudentExport implements FromCollection, WithHeadings, WithMapping,WithColumnWidths
{
    /**
    * @return \Illuminate\Support\Collection
    */
    protected $users;
    protected $key = 0;
    public function __construct($users)
    {
        $this->users = $users;
    }

    public function collection()
    {
        return $this->users;
    }

    public function headings(): array
    {
        return [
            'Matricule',
            'Classe',
            'Nom Complet',
            'Info Parent',
            'No_telephone',
            'No_telephone_urg',
            'Date_naissance',
            'Adresse',
            'Document',
            'No_document',
            'Statut',
            'Date_register',
        ];
    }

    public function map($value): array
    {
        $this->key++;
        $value_id = $value->usr_id;
        $status = $value->usr_status;
        $short_number = $value->usr_nb_court;
        $name = $value->usr_name;
        $birth = $value->usr_birth;
        $birth_address = $value->usr_birth_adresse;
        $sexe = $value->usr_sexe;
        $phone = $value->usr_phone;
        $phone_replace = str_ireplace('+237','',$phone);
        $phone_urgence = $value->usr_phone_urgence;
        $phone_urg_replace = str_ireplace('+237','',$phone_urgence);
        $address = $value->usr_adresse;
        $doc = $value->usr_doc_name;
        $doc_id = $value->usr_doc_id;
        $name_parent = $value->name_parent;
        $date_reg = $value->date_reg;
        $date_reg_format = Carbon::parse($date_reg)->format('d-m-Y');
        $className = getClassNameSchool($value_id);

        if ($status == 1) {
        $status_name = "INSCRIS";
        } elseif ($status == 0) {
        $status_name = " NON INSCRIS";
        } elseif ($status == 2) {
        $status_name = "REJETE";
        } else {
        $status_name = "STATUT";
        }
        return [
            // $this->key,
            $short_number,
            $className,
            $name,
            $name_parent,
            $phone_replace,
            $phone_urg_replace,
            $birth,
            $address,
            mb_strtoupper($doc),
            $doc_id,
            $status_name,
            $date_reg_format,
       