Index: app/Http/Controllers/Dashboard/DepartmentsController.php
===================================================================
--- app/Http/Controllers/Dashboard/DepartmentsController.php	(revision 4b7e2d354e16238fe8e560dc6dd0849218183335)
+++ app/Http/Controllers/Dashboard/DepartmentsController.php	(revision 159e7df5cac7501076108bf1a80ef55c96981454)
@@ -124,33 +124,26 @@
         $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
         $path = Storage::disk('uploads')->path('Departments');
-        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
-        $flag=false;
 
-        foreach ($files as $file)
-        {
-            if(File::all()->count() > 0) {
+        try {
+            $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+            $flag = false;
 
-                // We're skipping all subfolders
-                if (!$file->isDir()) {
-                    $filePath = $file->getRealPath();
-                    // extracting filename with substr/strlen
-                    $relativePath = substr($filePath, strlen($path) + 1);
-                    $zip->addFile($filePath, $relativePath);
+            foreach ($files as $file) {
+
+                    // We're skipping all subfolders
+                    if (!$file->isDir()) {
+                        $filePath = $file->getRealPath();
+                        // extracting filename with substr/strlen
+                        $relativePath = substr($filePath, strlen($path) + 1);
+                        $zip->addFile($filePath, $relativePath);
+                    }
                 }
-            }
-            else
-            {
-                $flag=true;
-            break;
-            }
+                $zip->close();
+                $headers = array('Content-Type' => 'application/octet-stream');
+                $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . '- Departments.zip';
+                return response()->download($zip_file, $zip_new_name, $headers);
         }
-        if(!$flag) {
-            $zip->close();
-            $headers = array('Content-Type' => 'application/octet-stream');
-            $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . '- Departments.zip';
-            return response()->download($zip_file, $zip_new_name, $headers);
-        }
-        else {
-            Alert::flash("All departments are empty", "warning");
+        catch(\Exception $e){
+           Alert::flash("All departments are empty", "warning");
             return redirect()->back();
         }
@@ -166,27 +159,24 @@
         $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
         $path = Storage::disk('uploads')->path($department->location) . DIRECTORY_SEPARATOR;
-        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
 
-        $filesInDept = $FileSystem->allFiles($path);
-
-        if(!empty($filesInDept)) {
-        foreach ($files as $file) {
-            if (!$file->isDir()) {
-                $filePath = $file->getRealPath();
-                // extracting filename with substr/strlen
-                $relativePath = substr($filePath, strlen($path) + 1);
-                $zip->addFile($filePath, $relativePath);
-            }
+        try{
+            $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+            foreach ($files as $file) {
+                if (!$file->isDir()) {
+                    $filePath = $file->getRealPath();
+                    // extracting filename with substr/strlen
+                    $relativePath = substr($filePath, strlen($path) + 1);
+                    $zip->addFile($filePath, $relativePath);
+                }
+            $zip->close();
+            $headers = array('Content-Type' => 'application/octet-stream',);
+            $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . $department->name . '.zip';
+            return response()->download($zip_file, $zip_new_name, $headers);
         }
-        $zip->close();
-        $headers = array('Content-Type' => 'application/octet-stream',);
-            $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . $department->name . '.zip';
-        return response()->download($zip_file, $zip_new_name, $headers);
-        }
-        else{
+    }
+    catch(\Exception $e) {
             Alert::flash("This department has no files", "warning");
             return redirect()->back();
-        }
-
+    }
     }
 }
