<?php

namespace App\Imports;

use App\Models\Pettycashexpense;
use App\Models\Carmodel;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class Importpetty_cash implements ToModel ,WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function startRow(): int
    {
        return 6;
    }
    
    public function model(array $row)
    {
        $data = [
            'expense_title' => $row['expense_title'],
            'amount' => $row['amount'],
            'created_at' => date('Y-m-d H:i:s'),
            'created_by' => auth()->user()->id,
            'updated_at' => date('Y-m-d H:i:s'),
            'updated_by' => auth()->user()->id
        ];
        $insurance = Pettycashexpense::create($data);
        return $insurance;
    }
}
