<?php

namespace App\Imports;

use App\Models\Destination;
use Maatwebsite\Excel\Row;
use Maatwebsite\Excel\Concerns\OnEachRow;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class DestinationsImport implements OnEachRow, WithHeadingRow
{
    public function onRow(Row $row)
    {
        $data = $row->toArray();
        
        Destination::updateOrCreate(
            ['name' => $data['name']],
            ['fare' => $data['fare'] ?? 0]
        );
    }
}