dasK_
Field is required CSV Importer
dd($this->data);
in resolveRecord after removing the requiredMapping and rules for required
array:7 [▼ // app\Filament\Imports\ProviderImporter.php:35
"ID" => "174"
"Name" => "Vodafone Albania"
"Logo url" => ""
"Network type" => "4g"
"Country" => "Albania"
"Created at" => "2024-02-08 03:48:26"
"Updated at" => "2024-02-08 03:59:41"
]
34 replies
Field is required CSV Importer
Sorry for late reply,
class ProviderImporter extends Importer
{
protected static ?string $model = Provider::class;
public static function getColumns(): array
{
return [
ImportColumn::make('name')
->label('Name')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('logoUrl')
->rules(['max:255']),
ImportColumn::make('network_type')
->rules(['max:255']),
// ImportColumn::make('country')
// ->relationship(resolveUsing: function ($state) {
// return Country::where('name', $state)->first()?->id;
// })
];
}
public function resolveRecord(): ?Provider
{
return Provider::firstOrNew([
'name' => $this->data['Name'],
]);
return new Provider();
}
Note: I commented out the relationship column just to show that I'm not doing anything complicated34 replies
Field is required CSV Importer
I'm seeing this in console
livewire.js?id=a27c4ca2:347 Uncaught TypeError: Cannot read properties of null (reading 'name')
double checked the csv, looks fine, I even did a dd in resolveRecord after taking the required selections out of the getColumns, that returned the correct array..
34 replies