Index: app/Http/Controllers/Dashboard/DepartmentsController.php
===================================================================
--- app/Http/Controllers/Dashboard/DepartmentsController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/DepartmentsController.php	(revision 2eee9a0f2751c62c1334de601bbeea6be55c4f3b)
@@ -147,5 +147,5 @@
         if(!$flag) {
             $zip->close();
-            $headers = array('Content-Type' => 'application/octet-stream',);
+            $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);
@@ -153,5 +153,5 @@
         else {
             Alert::flash("All departments are empty", "warning");
-            return redirect()->route("dashboard.departments.index");
+            return redirect()->back();
         }
     }
@@ -186,5 +186,5 @@
         else{
             Alert::flash("This department has no files", "warning");
-            return redirect()->route("dashboard.departments.index");
+            return redirect()->back();
         }
 
Index: app/Http/Controllers/Dashboard/ExportExcelController.php
===================================================================
--- app/Http/Controllers/Dashboard/ExportExcelController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/ExportExcelController.php	(revision 2eee9a0f2751c62c1334de601bbeea6be55c4f3b)
@@ -3,4 +3,5 @@
 namespace App\Http\Controllers\Dashboard;
 
+use App\Exports\DepartmentsExport;
 use App\Exports\FilesExport;
 use App\Exports\FoldersExport;
@@ -32,3 +33,10 @@
 
     }
+
+    public function ExportDepartments()
+    {
+        return Excel::download(new DepartmentsExport(), Carbon::now()->format('d.m.Y - H:i') . ' - departments.xlsx');
+
+    }
+
 }
Index: app/Http/Controllers/Dashboard/FilesController.php
===================================================================
--- app/Http/Controllers/Dashboard/FilesController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/FilesController.php	(revision 2eee9a0f2751c62c1334de601bbeea6be55c4f3b)
@@ -26,5 +26,5 @@
             "textExt" => array("txt", "doc", "docx"),
             "imageExt" => array("png", "jpg", "jpeg"),
-            "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))
+            "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes))
         ]);
     }
@@ -35,4 +35,5 @@
         $file->delete();
         Storage::disk('uploads')->delete($file->location);
+        $file->folder()->decrement('no_of_files');
 
         Alert::flash($file->name . " deleted successfully");
@@ -59,4 +60,5 @@
                 $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
                 $newFile->folder()->associate($folder);
+                $newFile->folder()->increment('no_of_files');
                 $newFile->save();
             }
@@ -65,10 +67,10 @@
             Alert::flash("New files added successfully");
 
-            return redirect()->route("dashboard.files.index");
+            return redirect()->back();
         }
         else {
             Alert::flash("No files were uploaded", "error");
 
-            return redirect()->route("dashboard.files.index");
+            return redirect()->back();
         }
     }
Index: app/Http/Controllers/Dashboard/FoldersController.php
===================================================================
--- app/Http/Controllers/Dashboard/FoldersController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/FoldersController.php	(revision 2eee9a0f2751c62c1334de601bbeea6be55c4f3b)
@@ -39,4 +39,7 @@
                 $folders = $foldersInDeptSort->orderBy('name', 'asc')->paginate(12);
             }
+            else if ($request->query('sort') == 'no_of_files') {
+                $folders = $foldersInDeptSort->orderBy('no_of_files', 'desc')->paginate(12);
+            }
             else if($request->query('sort') == 'count'){
                 $total = $foldersInDeptSort->folder->files->count();
@@ -52,4 +55,7 @@
             else if ($request->query('sort') == 'name') {
                 $folders = Folder::orderBy('name', 'asc')->paginate(12);
+            }
+            else if ($request->query('sort') == 'no_of_files') {
+                $folders = Folder::orderBy('no_of_files', 'desc')->paginate(12);
             }
             else if ($request->query('sort') == 'important') {
@@ -97,5 +103,5 @@
             "deptName" => $deptName,
             "deptCode" => $deptCode,
-            "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))
+            "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes))
         ]);
 
@@ -117,4 +123,5 @@
         $folder->user()->associate($user);
         $folder->department()->associate($department);
+        $folder->department()->increment('no_of_folders');
 
         $folder->arch_id = $request->arch_id;
@@ -149,4 +156,5 @@
                 $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
                 $newFile->folder()->associate($folder);
+                $newFile->folder()->increment('no_of_files');
                 $newFile->save();
             }
@@ -155,5 +163,5 @@
         Alert::flash("New folder created successfully");
 
-        return redirect()->route("dashboard.folders.index");
+        return redirect()->back();
     }
 
@@ -177,7 +185,7 @@
         $department = Department::find($request->department);
 
-        $folder->department()->associate($department);
-
-        $oldLocation = $folder->department->location . DIRECTORY_SEPARATOR . $folder->name;
+        $folder->department()->increment('no_of_folders');
+
+        $oldLocation = $folder->location;
 
         $folder->name = $request->name;
@@ -186,32 +194,44 @@
         $folder->updated_at = Carbon::now();
 
-        $location = $folder->department->location . DIRECTORY_SEPARATOR . $request->name;
-
-        if ($folder->isDirty('name')) {
-            if (!Storage::disk('uploads')->has($location)) {
-                Storage::disk('uploads')->move($oldLocation, $location);
-                foreach($files as $file){
-                    $file->location = $location . DIRECTORY_SEPARATOR . $file->name;
+       $newLocation = Department::find($request->department)->location . DIRECTORY_SEPARATOR . $request->name;
+
+        if($folder->department_id != $request->department){
+            $folder->department()->decrement('no_of_folders');
+            if (!Storage::disk('uploads')->has($newLocation)) {
+                Storage::disk('uploads')->move($oldLocation, $newLocation);
+                foreach($files as $file) {
+                    $file->location = $newLocation . DIRECTORY_SEPARATOR . $file->name;
                     $file->save();
                 }
             }
         }
+         if($folder->isDirty('name')) {
+            if (!Storage::disk('uploads')->has($newLocation)) {
+                Storage::disk('uploads')->move($oldLocation, $newLocation);
+                foreach($files as $file) {
+                    $file->location = $newLocation . DIRECTORY_SEPARATOR . $file->name;
+                    $file->save();
+                }
+            }
+        }
+
+        $folder->department()->associate($department);
+
+        $folder->location = $newLocation;
 
         if ($request->has('file_item')) {
             foreach ($request->file_item as $file) {
                 $fileName = $folder->name . '-' . uniqid() . '.' . $file->getClientOriginalExtension();
-                    $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName);
+                    $file->storeAs($newLocation . DIRECTORY_SEPARATOR, $fileName);
                     $newFile = new File();
                     $newFile->name = $fileName;
-                    $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
+                    $newFile->location = $newLocation . DIRECTORY_SEPARATOR . $fileName;
                     $newFile->folder()->associate($folder);
+                    $newFile->folder()->increment('no_of_files');
                     $newFile->save();
             }
         }
 
-        $folder->location = $location;
-
         $folder->save();
-
 
         Alert::flash("Folder edited successfully");
@@ -246,8 +266,10 @@
             $location = $folder->department->location . DIRECTORY_SEPARATOR . $folder->name;
             Storage::disk('uploads')->deleteDirectory($location);
+            $folder->department()->decrement('no_of_folders');
             Alert::flash($folder->name . " deleted successfully");
+            return redirect()->back();
         }
         Alert::flash($folder->name . " is important", "error");
-        return redirect()->route("dashboard.folders.index");
+        return redirect()->back();
     }
 
@@ -306,5 +328,5 @@
         }
         else {
-            $files = File::where('folder_id', $id)->paginate(10);
+            $files = File::where('folder_id', $id)->paginate(12);
         }
 
@@ -317,5 +339,5 @@
             "imageExt" => array("png", "jpg", "jpeg"),
             "folders" => $folders,
-            "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))
+            "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes))
         ]);
     }
Index: app/Http/Controllers/Dashboard/IndexController.php
===================================================================
--- app/Http/Controllers/Dashboard/IndexController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/IndexController.php	(revision 2eee9a0f2751c62c1334de601bbeea6be55c4f3b)
@@ -9,4 +9,6 @@
 use App\Models\User;
 use App\Http\Controllers\Controller;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\DB;
 
 class IndexController extends Controller
@@ -18,10 +20,28 @@
         );
 
+        $date = Carbon::today()->subDays(5);
+        $recentFiles = File::where('created_at', '>=', $date)->get();
+
+        $year = ['2021','2022','2023','2024', '2025'];
+
+        $file = [];
+        foreach ($year as $key => $value) {
+            $file[] = File::where(DB::raw("DATE_FORMAT(created_at, '%Y')"),$value)->count();
+        }
+
         return view("dashboard.index")->with([
             "counters" => $counters,
+            "largestDepartments" => Department::orderBy('no_of_folders', 'desc')->limit(10)->get(),
+            "folders" => Folder::all(),
+            "files" => File::all(),
+            "recentFiles" => $recentFiles,
+            "year" => json_encode($year,JSON_NUMERIC_CHECK),
+            "file" => json_encode($file,JSON_NUMERIC_CHECK),
             "departments" => Department::all(),
-            "folders" => Folder::all(),
-            "files" => File::all()
-        ]);
+            "excelExt" => array("xls", "xlsx", "xls", "csv"),
+            "textExt" => array("txt", "doc", "docx"),
+            "imageExt" => array("png", "jpg", "jpeg"),
+
+         ]);
     }
 }
Index: app/Http/Controllers/Dashboard/SettingsController.php
===================================================================
--- app/Http/Controllers/Dashboard/SettingsController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/SettingsController.php	(revision 2eee9a0f2751c62c1334de601bbeea6be55c4f3b)
@@ -77,6 +77,4 @@
     }
 
-
-
     public function fileTypes(FileTypeRequest $request)
     {
