File tree 3 files changed +14
-11
lines changed
3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ public function handleCsvProperties(): array|MessageBag
54
54
Log::warning ($ exception ->getMessage ());
55
55
56
56
return $ this ->addError (
57
- 'file_error ' ,
58
- __ ('Your CSV file has error/errors, or is empty. Please check, and try again ' )
57
+ 'file ' ,
58
+ __ ('The file has error/errors, Please check, and try again ' )
59
59
);
60
60
}
61
61
}
Original file line number Diff line number Diff line change @@ -114,17 +114,20 @@ protected function rules()
114
114
115
115
protected function setCsvProperties ()
116
116
{
117
+ if (! $ this ->handleCsvProperties () instanceof MessageBag) {
118
+ return [
119
+ $ this ->fileHeaders ,
120
+ $ this ->fileRowCount
121
+ ] = $ this ->handleCsvProperties ();
122
+ }
123
+
117
124
$ this ->withValidator (function (Validator $ validator ) {
118
125
$ validator ->after (function ($ validator ) {
119
- if ($ this ->handleCsvProperties () instanceof MessageBag) {
120
- $ validator ->errors ()->merge (
121
- $ this ->handleCsvProperties ()->getMessages ()
122
- );
123
- }
126
+ $ validator ->errors ()->merge (
127
+ $ this ->handleCsvProperties ()->getMessages ()
128
+ );
124
129
});
125
130
})->validate ();
126
-
127
- [$ this ->fileHeaders , $ this ->fileRowCount ] = $ this ->handleCsvProperties ();
128
131
}
129
132
130
133
protected function importCsv ()
Original file line number Diff line number Diff line change 53
53
])
54
54
->set ('file ' , $ file )
55
55
->assertSet ('model ' , $ model )
56
- ->assertHasErrors (['file_error ' ]);
56
+ ->assertHasErrors (['file ' ]);
57
57
});
58
58
59
59
it ('throws a validation error if the csv file has duplicate headers ' , function () {
70
70
])
71
71
->set ('file ' , $ file )
72
72
->assertSet ('model ' , $ model )
73
- ->assertHasErrors (['file_error ' ]);
73
+ ->assertHasErrors (['file ' ]);
74
74
});
75
75
76
76
it ('transfers columnsToMap into an associative array ' , function () {
You can’t perform that action at this time.
0 commit comments