36 lines
740 B
PHP
36 lines
740 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Imports;
|
|
|
|
use Illuminate\Support\Collection;
|
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
|
|
class EmployeesImport implements ToCollection, WithHeadingRow
|
|
{
|
|
/** @var Collection<int, array<string, mixed>> */
|
|
private Collection $rows;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->rows = collect();
|
|
}
|
|
|
|
public function collection(Collection $rows): void
|
|
{
|
|
$this->rows = $rows->map(
|
|
fn (Collection $row): array => $row->toArray(),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, array<string, mixed>>
|
|
*/
|
|
public function getRows(): Collection
|
|
{
|
|
return $this->rows;
|
|
}
|
|
}
|