Changeset 4521f25 for app/Http/Controllers/Dashboard
- Timestamp:
- 10/31/21 22:09:08 (3 years ago)
- Branches:
- master
- Children:
- 8fdb18e
- Parents:
- e78295c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/FoldersController.php
re78295c r4521f25 4 4 5 5 use App\Helpers\Alert; 6 use App\Http\Requests\Dashboard\FileRequest; 6 7 use App\Http\Requests\Dashboard\FolderRequest; 7 8 use App\Http\Requests\Dashboard\FileNameRequest; … … 186 187 } 187 188 189 public function uploadFiles(FileRequest $request, $id) 190 { 191 $file = new File(); 192 193 $folder = Folder::findOrFail($id); 194 195 $location = $folder->location; 196 197 $users = User::all(); 198 199 if ($request->has('file_item')) { 200 foreach ($request->file_item as $file) { 201 $fileName = $file->getClientOriginalName(); 202 203 if(File::where(['folder_id' => $folder->id, 'name' => $fileName])->count() > 0) { 204 Alert::flash("The uploaded file already exists", "error"); 205 206 return redirect()->back(); 207 } 208 209 $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName); 210 $newFile = new File(); 211 $newFile->name = $fileName; 212 $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName; 213 //$newFile->folder()->associate($folder); 214 $newFile->folder()->associate($folder); 215 $newFile->folder()->increment('no_of_files'); 216 $newFile->save(); 217 } 218 219 Alert::flash("New files added successfully"); 220 221 return redirect()->back(); 222 } 223 else { 224 Alert::flash("No files were uploaded", "error"); 225 226 return redirect()->back(); 227 } 228 } 229 188 230 public function destroy($id) 189 231 {
Note:
See TracChangeset
for help on using the changeset viewer.