Index: app/Http/Controllers/Dashboard/FilesController.php
===================================================================
--- app/Http/Controllers/Dashboard/FilesController.php	(revision aab55f4d6561efb46a5737756dbfac8af98947a4)
+++ app/Http/Controllers/Dashboard/FilesController.php	(revision e78295cd8068c5cafb2b4988541373f115ca6443)
@@ -54,5 +54,12 @@
         if ($request->has('file_item')) {
             foreach ($request->file_item as $file) {
-                $fileName = $folder->name . '-' . uniqid() . '.' . $file->getClientOriginalExtension();
+                $fileName = $file->getClientOriginalName();
+
+                if(File::where(['folder_id' => $folder->id, 'name' => $fileName])->count() > 0) {
+                    Alert::flash("The uploaded file already exists", "error");
+
+                    return redirect()->back();
+                }
+
                 $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName);
                 $newFile = new File();
@@ -63,5 +70,4 @@
                 $newFile->save();
             }
-            Notification::send($users, new NewFileCreated("New files added"));
 
             Alert::flash("New files added successfully");
@@ -81,27 +87,3 @@
         return Storage::download($file->location);
     }
-
-    public function renameFile(FileNameRequest $request, $id)
-    {
-        $file = File::find($id);
-        $fileExtension = explode('.', $file->name)[1];
-
-        $file->name = $request->name . '.' . $fileExtension;
-        $newLocation = 'Departments' . DIRECTORY_SEPARATOR . explode(DIRECTORY_SEPARATOR, $file->location)[1] . DIRECTORY_SEPARATOR . explode(DIRECTORY_SEPARATOR, $file->location)[2] . DIRECTORY_SEPARATOR . $file->name;
-
-        if(Storage::disk('uploads')->has($newLocation)) {
-            Alert::flash("A file with the same name already exists", "error");
-            return redirect()->back();
-        }
-        else {
-            Storage::disk('uploads')->move($file->location, $newLocation);
-
-            $file->location = $newLocation;
-            $file->updated_at = Carbon::now();
-            $file->save();
-
-            Alert::flash($file->name . " updated successfully");
-            return redirect()->back();
-        }
-    }
 }
Index: app/Http/Controllers/Dashboard/FoldersController.php
===================================================================
--- app/Http/Controllers/Dashboard/FoldersController.php	(revision aab55f4d6561efb46a5737756dbfac8af98947a4)
+++ app/Http/Controllers/Dashboard/FoldersController.php	(revision e78295cd8068c5cafb2b4988541373f115ca6443)
@@ -18,4 +18,5 @@
 use Illuminate\Support\Facades\Storage;
 use App\Http\Controllers\Controller;
+use function Sodium\increment;
 
 class FoldersController extends Controller
@@ -58,7 +59,4 @@
             else if ($request->query('sort') == 'no_of_files') {
                 $folders = Folder::orderBy('no_of_files', 'desc')->paginate(12);
-            }
-            else if ($request->query('sort') == 'important') {
-                $folders = Folder::where('is_important', true)->paginate(12);
             }
             else if ($request->query('sort') == 'recent') {
@@ -96,5 +94,4 @@
             "docsCount" => Department::withCount('folder')->get(),
             "totalDocs" => Folder::all()->count(),
-            "countImportant" => Folder::where('is_important', true)->get()->count(),
             "diskTotal" => $diskTotal,
             "diskTotalSize" => $diskTotalSize,
@@ -118,6 +115,23 @@
     {
         $folder = new Folder();
+
+        $existingFolder = Folder::where(['department_id' => $request->department, 'name' => $request->name, 'arch_id' => $request->arch_id])->count();
+
+        $existingFolderName = Folder::where(['department_id' => $request->department, 'name' => $request->name])->count();
+        $existingFolderArchId = Folder::where(['department_id' => $request->department, 'arch_id' => $request->arch_id])->count();
+
+        if($existingFolder > 0) {
+            $folder->version = $existingFolder + 1;
+        }
+
+        if(($existingFolderName > 0 && $existingFolderArchId <= 0) || ($existingFolderName <= 0 && $existingFolderArchId > 0)) {
+            Alert::flash("Can't create another version since folder name or archive ID is different", "error");
+
+            return redirect()->route("dashboard.folders.index");
+        }
+
+        $department = Department::find($request->department);
+
         $user = auth()->user();
-        $department = Department::find($request->department);
 
         $folder->user()->associate($user);
@@ -128,10 +142,4 @@
         $folder->name = $request->name;
         $folder->note = $request->note;
-
-        if($request->has('is_important')){
-            $folder->is_important = true;
-        }else{
-            $folder->is_important = false;
-        }
 
         $location = $folder->department->location . DIRECTORY_SEPARATOR . $request->name;
@@ -178,89 +186,28 @@
     }
 
-    public function edit(FolderRequest $request, $id)
-    {
-        $folder = Folder::findOrFail($id);
+    public function destroy($id)
+    {
+        $folder = Folder::find($id);
+
+        $existingFolders = Folder::where(['department_id' => $folder->department->id, 'name' => $folder->name, 'arch_id' => $folder->arch_id])->count();
+
+        if($existingFolders > 1 && $folder->version == 1) {
+            Alert::flash($folder->name . " has versions", "error");
+            return redirect()->back();
+        }
+
         $files = File::where('folder_id', $id)->get();
 
-        $department = Department::find($request->department);
-
-        $folder->department()->increment('no_of_folders');
-
-        $oldLocation = $folder->location;
-
-        $folder->name = $request->name;
-        $folder->arch_id = $request->arch_id;
-        $folder->note = $request->note;
-        $folder->updated_at = Carbon::now();
-
-       $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($newLocation . DIRECTORY_SEPARATOR, $fileName);
-                    $newFile = new File();
-                    $newFile->name = $fileName;
-                    $newFile->location = $newLocation . DIRECTORY_SEPARATOR . $fileName;
-                    $newFile->folder()->associate($folder);
-                    $newFile->folder()->increment('no_of_files');
-                    $newFile->save();
-            }
-        }
-
-        $folder->save();
-
-        Alert::flash("Folder edited successfully");
-
-        return redirect()->back();
-    }
-
-    public function toggleImportant($id)
-    {
-        $folder = Folder::find($id);
-        $folder->is_important = !$folder->is_important;
-        $folder->save();
-
-        if ($folder->is_important == true)
-            Alert::flash("Folder marked as important successfully");
-        else
-            Alert::flash("Folder marked as not important successfully");
-
-        return redirect()->back();
-    }
-
-    public function destroy($id)
-    {
-        $folder = Folder::find($id);
-        $files = File::where('folder_id', $id)->get();
-        if (auth()->user()->hasPermission("delete_all_folders") && !$folder->is_important) {
+        if($files->count() > 0) {
+            Alert::flash($folder->name . " contains files", "error");
+            return redirect()->back();
+        }
+
+        if (auth()->user()->hasPermission("delete_all_folders")) {
 
             foreach ($files as $file) {
                 $file->delete();
             }
+
             $folder->delete();
             $location = $folder->department->location . DIRECTORY_SEPARATOR . $folder->name;
@@ -270,5 +217,5 @@
             return redirect()->back();
         }
-        Alert::flash($folder->name . " is important", "error");
+        Alert::flash($folder->name . " cannot be deleted", "error");
         return redirect()->back();
     }
@@ -337,5 +284,5 @@
             "imageExt" => array("png", "jpg", "jpeg"),
             "folders" => $folders,
-            "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes))
+            "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes)),
         ]);
     }
Index: app/Http/Requests/Dashboard/FolderRequest.php
===================================================================
--- app/Http/Requests/Dashboard/FolderRequest.php	(revision aab55f4d6561efb46a5737756dbfac8af98947a4)
+++ app/Http/Requests/Dashboard/FolderRequest.php	(revision e78295cd8068c5cafb2b4988541373f115ca6443)
@@ -35,5 +35,4 @@
             "arch_id" => [
                 "required",
-                "unique:folders,arch_id,$this->id,id",
                 function ($attribute, $value, $fail) {
 
