<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 Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithColumnWidths;

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

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

    public function headings(): array
    {
        return [
            'No',
            'Proprietaire',
            'No_Telephone',
            'Ligne',
            'Marque',
            'Modele',
            'plaque',
            'Chassit',
            'Annee',
            'Date_register',
        ];
    }

    public function map($value): array
    {
        $this->key++;
        return [
            $this->key,
            isset($value->user) ? $value->user->usr_name : "",
            isset($value->user) ? $value->user->usr_phone : "",
            isset($value->line) ? $value->line->arr_name : "RAS",
            isset($value->Brand) ? $value->Brand->mrq_name : "",
            isset($value->Model) ? $value->Model->smrq_name : "",
            mb_strtoupper($value->usr_nationality),
            $value->ud_no_plaquee,
            $value->ud_chassis,
            $value->ud_annee_engin,
            $value->date_reg,
       