funcion/arreglar-planillas #43

Merged
atasistro merged 22 commits from funcion/arreglar-planillas into master 2025-05-12 19:42:28 -03:00
Showing only changes of commit 7c7149c5a1 - Show all commits

26
app/Helpers/CsvHelper.php Normal file
View file

@ -0,0 +1,26 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\Log;
use Iterator;
use League\Csv\Exception;
use League\Csv\InvalidArgument;
use League\Csv\Reader;
class CsvHelper
{
public static function getRecords($filePath): Iterator {
$csv = Reader::createFromPath(resource_path($filePath), 'r');
try {
$csv->setDelimiter("|");
$csv->setEnclosure("'");
$csv->setHeaderOffset(0);
return $csv->getRecords();
} catch (InvalidArgument|Exception $e) {
Log::error($e->getMessage());
return null;
}
}
}