- Timestamp:
- 10/24/21 23:23:54 (3 years ago)
- Branches:
- develop, master
- Children:
- df6e9ec
- Parents:
- fa80fbe
- Location:
- app/Http
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
rfa80fbe r94f05dc 47 47 48 48 $users = User::all(); 49 Notification::send($users, new NewDepartmentCreated("New department created"));50 49 51 50 $department->save(); … … 127 126 try { 128 127 $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); 129 $flag = false;130 131 128 foreach ($files as $file) { 132 129 … … 154 151 $department = Department::find($id); 155 152 156 $FileSystem = new Filesystem(); 157 $zip_file = Storage::disk('uploads')->path('Department.zip'); 153 $zip_file=Storage::disk('uploads')->path('Department.zip'); 158 154 $zip = new \ZipArchive(); 159 155 $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); 160 $path = Storage::disk('uploads')->path($department->location) . DIRECTORY_SEPARATOR;156 $path = Storage::disk('uploads')->path($department->location); 161 157 162 try {158 try { 163 159 $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); 164 160 foreach ($files as $file) { 161 162 // We're skipping all subfolders 165 163 if (!$file->isDir()) { 166 164 $filePath = $file->getRealPath(); … … 169 167 $zip->addFile($filePath, $relativePath); 170 168 } 169 } 171 170 $zip->close(); 172 $headers = array('Content-Type' => 'application/octet-stream' ,);173 $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . $department->name . '.zip';171 $headers = array('Content-Type' => 'application/octet-stream'); 172 $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . '- Departments.zip'; 174 173 return response()->download($zip_file, $zip_new_name, $headers); 175 174 } 176 } 177 catch(\Exception $e) { 178 Alert::flash("This department has no files", "warning"); 175 catch(\Exception $e){ 176 Alert::flash("All departments are empty", "warning"); 179 177 return redirect()->back(); 180 }178 } 181 179 } 182 180 } -
app/Http/Controllers/Dashboard/FoldersController.php
rfa80fbe r94f05dc 163 163 Alert::flash("New folder created successfully"); 164 164 165 return redirect()-> back();165 return redirect()->route("dashboard.folders.index"); 166 166 } 167 167 -
app/Http/Requests/Dashboard/FolderRequest.php
rfa80fbe r94f05dc 41 41 $arch_id = $this->request->get('arch_id'); 42 42 43 $dept Id= explode('/', $arch_id)[0];43 $deptCode = explode('/', $arch_id)[0]; 44 44 $archNum = explode('/', $arch_id)[1]; 45 45 … … 48 48 } 49 49 50 if ($dept Id !== Department::find($this->request->get('department'))->code) {50 if ($deptCode != Department::find($this->request->get('department'))->code) { 51 51 $fail("Folder Archive ID field format is invalid"); 52 52 } 53 } catch (\Exception $e) { 53 } 54 catch (\Exception $e) { 54 55 $fail("Please enter folders Archive ID"); 55 56 }
Note:
See TracChangeset
for help on using the changeset viewer.