<?php

namespace App\Exports;

use App\Models\Customer;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;

class CustomersExport implements FromCollection  , WithHeadings , ShouldAutoSize 
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        $collections = Customer::all();

        foreach($collections as  $item){
            unset($item->id,$item->password,$item->user_id,$item->total_order,$item->email,$item->image,$item->customer_type , $item->city_id, $item->sub_city_id, $item->remember_token, $item->status,$item->created_at,$item->updated_at );
             $collections[]=$item;
         }

        return $collections; 

    }
     
    public function headings():  array
    {
        return self::columnWidths( 'Name','Phone','Address');
    }
 

    public static function  columnWidths($name, $phone, $address): array {

         return [

                 $name, $phone, $address
         ];
    }




}
