Custom CSV Settings
By default Laravel Simplesheet uses the defaults from the config (config/simplesheet.php
). You can change this by adding the WithCustomCsvSettings interface.
namespace App\Imports;
use Nikazooz\Simplesheet\Concerns\ToModel;
use Nikazooz\Simplesheet\Concerns\WithCustomCsvSettings;
class UsersImport implements ToModel, WithCustomCsvSettings
{
public function model(array $row)
{
return new User([
'name' => $row['0'],
'email' => $row['1'],
]);
}
public function getCsvSettings(): array
{
return [
'delimiter' => ';',
];
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Available settings
delimiter
enclosure
line_ending
use_bom
include_separator_line
excel_compatibility