requiredMapping() ->numeric() ->exampleHeader('Plant Code') ->label('Plant Code') ->rules(['required']), //, 'integer' ImportColumn::make('company') ->requiredMapping() ->exampleHeader('Company Name') ->label('Company Name') ->relationship(resolveUsing:'name') ->rules(['required']), ImportColumn::make('name') ->requiredMapping() ->exampleHeader('Plant Name') ->label('Plant Name') ->rules(['required']), ImportColumn::make('address') ->requiredMapping() ->exampleHeader('Plant Address') ->label('Plant Address') ->rules(['required']), ]; } public function resolveRecord(): ?Plant { // return Plant::firstOrNew([ // // Update existing records, matching them by `$this->data['column_name']` // 'email' => $this->data['email'], // ]); return new Plant(); } public static function getCompletedNotificationBody(Import $import): string { $body = 'Your plant import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; if ($failedRowsCount = $import->getFailedRowsCount()) { $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; } return $body; } }