5
5
use Coderflex \LaravelCsv \Concerns ;
6
6
use Coderflex \LaravelCsv \Jobs \ImportCsv ;
7
7
use Coderflex \LaravelCsv \Utilities \ChunkIterator ;
8
+ use Illuminate \Support \Facades \Auth ;
8
9
use Illuminate \Support \Facades \Bus ;
9
10
use Illuminate \Support \MessageBag ;
10
11
use Illuminate \Validation \Validator ;
@@ -108,16 +109,6 @@ protected function setCsvProperties()
108
109
[$ this ->fileHeaders , $ this ->fileRowCount ] = $ this ->handleCsvProperties ();
109
110
}
110
111
111
- protected function createNewImport ()
112
- {
113
- return (new $ this ->model )->imports ()->create ([
114
- 'user_id ' => auth ()->id () ?? null ,
115
- 'file_path ' => $ this ->file ->getRealPath (),
116
- 'file_name ' => $ this ->file ->getClientOriginalName (),
117
- 'total_rows ' => $ this ->fileRowCount ,
118
- ]);
119
- }
120
-
121
112
protected function importCsv ()
122
113
{
123
114
$ import = $ this ->createNewImport ();
@@ -139,4 +130,17 @@ protected function importCsv()
139
130
fn () => $ import ->touch ('compoleted_at ' )
140
131
)->dispatch ();
141
132
}
133
+
134
+ protected function createNewImport ()
135
+ {
136
+ /** @var \Illuminate\Foundation\Auth\User */
137
+ $ user = auth ()->user ();
138
+
139
+ return $ user ->imports ()->create ([
140
+ 'model ' => $ this ->model ,
141
+ 'file_path ' => $ this ->file ->getRealPath (),
142
+ 'file_name ' => $ this ->file ->getClientOriginalName (),
143
+ 'total_rows ' => $ this ->fileRowCount ,
144
+ ]);
145
+ }
142
146
}
0 commit comments