<?php

namespace App\Imports;

use App\Models\Placement;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithGroupedHeadingRow;

class PlacementImport implements ToModel, WithHeadingRow, WithGroupedHeadingRow
{
    /**
     * @param array $row
     *
     * @return \Illuminate\Database\Eloquent\Model|null
     */
    public function model(array $row)
    {
        return new Placement([
            "soal" => $row["soal"],
            "jawaban" => join("|", $row["jawaban"]),
            "jawaban_benar" => $row["jawaban"][0]
        ]);
    }
}
