File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Expand file tree Collapse file tree 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
5454 Log::warning ($ exception ->getMessage ());
5555
5656 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 ' )
5959 );
6060 }
6161 }
Original file line number Diff line number Diff line change @@ -114,17 +114,20 @@ protected function rules()
114114
115115 protected function setCsvProperties ()
116116 {
117+ if (! $ this ->handleCsvProperties () instanceof MessageBag) {
118+ return [
119+ $ this ->fileHeaders ,
120+ $ this ->fileRowCount
121+ ] = $ this ->handleCsvProperties ();
122+ }
123+
117124 $ this ->withValidator (function (Validator $ validator ) {
118125 $ 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+ );
124129 });
125130 })->validate ();
126-
127- [$ this ->fileHeaders , $ this ->fileRowCount ] = $ this ->handleCsvProperties ();
128131 }
129132
130133 protected function importCsv ()
Original file line number Diff line number Diff line change 5353 ])
5454 ->set ('file ' , $ file )
5555 ->assertSet ('model ' , $ model )
56- ->assertHasErrors (['file_error ' ]);
56+ ->assertHasErrors (['file ' ]);
5757});
5858
5959it ('throws a validation error if the csv file has duplicate headers ' , function () {
7070 ])
7171 ->set ('file ' , $ file )
7272 ->assertSet ('model ' , $ model )
73- ->assertHasErrors (['file_error ' ]);
73+ ->assertHasErrors (['file ' ]);
7474});
7575
7676it ('transfers columnsToMap into an associative array ' , function () {
You can’t perform that action at this time.
0 commit comments