base commit
This commit is contained in:
35
app/Imports/EmployeesImport.php
Normal file
35
app/Imports/EmployeesImport.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user