<?php
namespace Maatwebsite\Excel;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToArray;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithCalculatedFormulas;
use Maatwebsite\Excel\Concerns\WithFormatData;
use Maatwebsite\Excel\Concerns\WithMappedCells;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class MappedReader
{
/**
* @param WithMappedCells $import
* @param Worksheet $worksheet
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function map(WithMappedCells $import, Worksheet $worksheet)
{
$mapped = $import->mapping();
array_walk_recursive($mapped, function (&$coordinate) use ($import, $worksheet) {
$cell = Cell::make($worksheet, $coordinate);
$coordinate = $cell->getValue(
null,
$import instanceof WithCalculatedFormulas,
$import instanceof WithFormatData
);
});
if ($import instanceof ToModel) {
$model = $import->model($mapped);
if ($model) {
$model->saveOrFail();
}
}
if ($import instanceof ToCollection) {
$import->collection(new Collection($mapped));
}
if ($import instanceof ToArray) {
$import->array($mapped);
}
}
}
Contact Section
We’d love to hear from you! Whether you have questions, feedback, or need support, our team is here to help. Reach out to us via email, phone, or visit our office. We’re committed to providing you with exceptional service and ensuring your experience with NFC Pay is seamless and satisfying. Let’s connect!