Index: app/Http/Controllers/Dashboard/DepartmentsController.php
===================================================================
--- app/Http/Controllers/Dashboard/DepartmentsController.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Controllers/Dashboard/DepartmentsController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -7,13 +7,12 @@
 use App\Http\Requests\Dashboard\UpdateDepartmentRequest;
 use App\Models\Department;
-use App\Models\Document;
 use App\Models\File;
 use App\Models\User;
+use App\Notifications\NewDepartmentCreated;
 use Carbon\Carbon;
-use Illuminate\Http\Request;
 use App\Http\Controllers\Controller;
-use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Notification;
 use Illuminate\Support\Facades\Storage;
-use function Illuminate\Events\queueable;
+use Illuminate\Filesystem\Filesystem;
 
 class DepartmentsController extends Controller
@@ -40,10 +39,13 @@
         $location = 'Departments' . DIRECTORY_SEPARATOR . $request->code;
 
-        if(!Storage::disk('local')->has($location)){
-            Storage::disk('local')->makeDirectory($location);
+        if(!Storage::disk('uploads')->has($location)){
+            Storage::disk('uploads')->makeDirectory($location);
 
         }
-        $department->location = Storage::disk('local')->path('') . $location;
+        $department->location = $location;
         $department->user_id = auth()->id();
+
+        $users = User::all();
+        Notification::send($users, new NewDepartmentCreated("New department created"));
 
         $department->save();
@@ -65,21 +67,25 @@
         $department = Department::findOrFail($id);
 
-        $documents = $department->document;
+        $folders = $department->folder;
         $oldLocation = DIRECTORY_SEPARATOR . 'Departments' . DIRECTORY_SEPARATOR . $department->code;
 
         $department->name = $request->name;
         $department->code = $request->code;
+        $department->updated_at = Carbon::now();
 
         if($department->isDirty('code'))
         {
             $location = 'Departments' . DIRECTORY_SEPARATOR . $request->code;
-            if(!Storage::disk('local')->has($location)){
-                Storage::disk('local')->move($oldLocation, $location);
-                $department->location = Storage::disk('local')->path('') . $location;
+            if(!Storage::disk('uploads')->has($location)){
+                Storage::disk('uploads')->move($oldLocation, $location);
+                $department->location = $location;
             }
 
-            foreach ($documents as $document) {
-                foreach($document->files as $file) {
-                    $file->location = $location . DIRECTORY_SEPARATOR . $document->name . DIRECTORY_SEPARATOR . $file->name;
+            foreach ($folders as $folder) {
+                    $currArchId = explode('/', $folder->arch_id)[1];
+                    $folder->arch_id = $department->code . '/' . $currArchId;
+                    $folder->save();
+                foreach($folder->files as $file) {
+                    $file->location = $location . DIRECTORY_SEPARATOR . $folder->name . DIRECTORY_SEPARATOR . $file->name;
                     $file->save();
                 }
@@ -98,8 +104,8 @@
         $department = Department::find($id);
         //$department->delete();
-        $documents = $department->document()->count();
+        $folders = $department->folder()->count();
 
-        if($documents > 0){
-            Alert::flash($department->name . " has " . $documents . " document/s associated", "error");
+        if($folders > 0){
+            Alert::flash($department->name . " has " . $folders . " document/s associated", "error");
         }
         else {
@@ -111,3 +117,76 @@
         return redirect()->route("dashboard.departments.index");
     }
+
+    public function downloadAll()
+    {
+        $zip_file=Storage::disk('uploads')->path('Departments.zip');
+        $zip = new \ZipArchive();
+        $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) {
+
+                // 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;
+            }
+        }
+        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");
+            return redirect()->route("dashboard.departments.index");
+        }
+    }
+
+    public function downloadDepartment($id)
+    {
+        $department = Department::find($id);
+
+        $FileSystem = new Filesystem();
+        $zip_file = Storage::disk('uploads')->path('Department.zip');
+        $zip = new \ZipArchive();
+        $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);
+            }
+        }
+        $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{
+            Alert::flash("This department has no files", "warning");
+            return redirect()->route("dashboard.departments.index");
+        }
+
+    }
 }
Index: app/Http/Controllers/Dashboard/DocumentsController.php
===================================================================
--- app/Http/Controllers/Dashboard/DocumentsController.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ 	(revision )
@@ -1,310 +1,0 @@
-<?php
-
-namespace App\Http\Controllers\Dashboard;
-
-use App\Helpers\Alert;
-use App\Http\Requests\Dashboard\DocumentRequest;
-use App\Http\Requests\Dashboard\FileRequest;
-use App\Http\Requests\Dashboard\PasswordSettingsRequest;
-use App\Models\Department;
-use App\Models\Document;
-use App\Models\File;
-use App\Services\UploadService;
-use Carbon\Carbon;
-use Illuminate\Http\Request;
-use Illuminate\Http\Response;
-use Illuminate\Support\Facades\Storage;
-use App\Http\Controllers\Controller;
-
-class DocumentsController extends Controller
-{
-    public function index(Request $request)
-    {
-        $queries = explode(" ", $request->search);
-        $result = collect();
-
-        foreach ($queries as $query) {
-            $result->push(Document::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get());
-        }
-
-        $result = $result->flatten();
-
-        $deptName = "";
-        $deptCode = "";
-
-        if ($request->query('id')) {
-            $deptName = Department::find($request->query('id'))->getOriginal('name');
-            $deptCode = Department::find($request->query('id'))->getOriginal('code');
-            $documentsInDeptSort = Document::with('department')->when($request->has('id'), function ($query) use ($request) {
-                $query->where('department_id', $request->query('id'));
-            });
-
-            if ($request->query('sort') == 'newest') {
-                $documents = $documentsInDeptSort->orderBy('created_at', 'desc')->paginate(16);
-            } else if ($request->query('sort') == 'name') {
-                $documents = $documentsInDeptSort->orderBy('name', 'asc')->paginate(16);
-            } else {
-                $documents = Document::where('department_id', $request->query('id'))->paginate(16);
-            }
-        } else {
-            if ($request->query('sort') == 'newest') {
-                $documents = Document::orderBy('created_at', 'desc')->paginate(16);
-            } else if ($request->query('sort') == 'name') {
-                $documents = Document::orderBy('name', 'asc')->paginate(16);
-            } else if ($request->query('sort') == 'important') {
-                $documents = Document::where('is_important', true)->paginate(16);
-            } else if ($request->query('sort') == 'recent') {
-                $documents = Document::orderBy('created_at', 'desc')->paginate(16);
-            } else if ($request->query('search')) {
-                $result = collect();
-
-                foreach ($queries as $query) {
-                    $result->push(Document::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get());
-                }
-                $result = $result->flatten();
-                $documents = $result;
-            } else {
-                $documents = Document::paginate(20);
-            }
-        }
-
-        $departments = Department::all();
-
-        $diskTotal = disk_total_space('/');
-        $diskTotalSize = $diskTotal / 1073741824;
-
-        $diskFree = disk_free_space('/');
-        $used = $diskTotal - $diskFree;
-
-        $diskUsedSize = $used / 1073741824;
-        $diskUse1 = round(100 - (($diskUsedSize / $diskTotalSize) * 100));
-        $diskUse = round(100 - ($diskUse1)) . '%';
-
-        return view("dashboard.documents.index")->with([
-            "documents" => $documents,
-            "currentUser" => auth()->user(),
-            "departments" => $departments,
-            "docsCount" => Department::withCount('document')->get(),
-            "totalDocs" => Document::all()->count(),
-            "countImportant" => Document::where('is_important', true)->get()->count(),
-            "diskTotal" => $diskTotal,
-            "diskTotalSize" => $diskTotalSize,
-            "diskUse" => $diskUse,
-            "diskUsedSize" => $diskUsedSize,
-            "deptName" => $deptName,
-            "deptCode" => $deptCode,
-
-        ]);
-
-    }
-
-    public function create()
-    {
-        return view("dashboard.documents.create")->with([
-            "departments" => Department::all()
-        ]);
-    }
-
-    public function store(DocumentRequest $request)
-    {
-        $document = new Document();
-        $user = auth()->user();
-        $department = Department::find($request->department);
-
-        $document->user()->associate($user);
-        $document->department()->associate($department);
-
-        $document->arch_id = $request->arch_id;
-        $document->name = $request->name;
-        $document->description = $request->description;
-
-        $location = 'Departments' . DIRECTORY_SEPARATOR . $document->department->code . DIRECTORY_SEPARATOR . $request->name;
-
-        if (!Storage::disk('local')->has($location)) {
-            Storage::disk('local')->makeDirectory($location);
-        }
-
-        $document->save();
-
-        if ($request->has('file_item')) {
-            foreach ($request->file_item as $file) {
-                $file->storeAs($location . DIRECTORY_SEPARATOR, $file->getClientOriginalName());
-                $newFile = new File();
-                $newFile->name = $file->getClientOriginalName();
-                $newFile->location = $location . DIRECTORY_SEPARATOR . $file->getClientOriginalName();
-                $newFile->document()->associate($document);
-                $newFile->save();
-            }
-        }
-
-        Alert::flash("New document created successfully");
-
-        return redirect()->route("dashboard.documents.index");
-    }
-
-    public function editShow($id)
-    {
-        return view("dashboard.documents.edit")->with([
-            "document" => Document::findOrFail($id),
-            "departments" => Department::all(),
-            "files" => File::where('document_id', $id)->get()
-        ]);
-    }
-
-    public function edit(DocumentRequest $request, $id)
-    {
-        $document = Document::findOrFail($id);
-        $files = File::where('document_id', $id)->get();
-
-        $department = Department::find($request->department);
-
-        $document->department()->associate($department);
-
-        $oldLocation = 'Departments' . DIRECTORY_SEPARATOR . $document->department->code . DIRECTORY_SEPARATOR . $document->name;
-
-        $document->name = $request->name;
-        $document->arch_id = $request->arch_id;
-        $document->description = $request->description;
-
-        $location = 'Departments' . DIRECTORY_SEPARATOR . $document->department->code . DIRECTORY_SEPARATOR . $request->name;
-
-        if ($document->isDirty('name')) {
-            if (!Storage::disk('local')->has($location)) {
-                Storage::disk('local')->move($oldLocation, $location);
-                foreach($files as $file){
-                    $file->location = $location . DIRECTORY_SEPARATOR . $file->name;
-                    $file->save();
-                }
-            }
-        }
-
-        if ($request->has('file_item')) {
-            foreach ($request->file_item as $file) {
-                $fileName = $file->getClientOriginalName();
-                if (Storage::disk('local')->has($location . DIRECTORY_SEPARATOR . $fileName)) {
-                    // $hasFileError = true;
-                    // break;
-                    $NewFileName = time() . $fileName;
-                    $file->storeAs($location . DIRECTORY_SEPARATOR, $NewFileName);
-                    $newFile = new File();
-                    $newFile->name = rand() . $fileName;
-                    $newFile->location = $location . DIRECTORY_SEPARATOR . $NewFileName;
-                    $newFile->document()->associate($document);
-                    $newFile->save();
-                } else {
-                    $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName);
-                    $newFile = new File();
-                    $newFile->name = $fileName;
-                    $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
-                    $newFile->document()->associate($document);
-                    $newFile->save();
-                }
-            }
-        }
-
-        $document->save();
-
-//        if($hasFileError) {
-//            Alert::flash('Document with the same name exists', 'error');
-//            return redirect()->route("dashboard.documents.edit", ['id' => $document->id]);
-//        }
-
-
-
-        Alert::flash("Document edited successfully");
-
-        return redirect()->back();
-    }
-
-    public function toggleImportant($id)
-    {
-        $document = Document::find($id);
-        $document->is_important = !$document->is_important;
-        $document->save();
-
-        if ($document->is_important == true)
-            Alert::flash("Document marked as important successfully");
-        else
-            Alert::flash("Document marked as not important successfully");
-
-        return redirect()->back();
-    }
-
-    public function search(Request $request)
-    {
-        $queries = explode(" ", $request->q);
-        $result = collect();
-
-        foreach ($queries as $query) {
-            $result->push(Document::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get());
-        }
-
-        $result = $result->flatten();
-
-        $departments = Department::all();
-
-        return view("dashboard.documents.search")
-            ->with("searchQuery", $request->q)
-            ->with("results", $result)
-            ->with("departments", $departments)
-            ->with("countImportant", Document::where('is_important', true)->get()->count());
-    }
-
-    public function destroy($id)
-    {
-        $document = Document::find($id);
-        $files = File::where('document_id', $id)->get();
-        if (auth()->user()->hasPermission("delete_all_documents")) {
-           // @dd($files);
-            foreach ($files as $file) {
-                $file->delete();
-            }
-            $document->delete();
-            $location = 'Departments' . DIRECTORY_SEPARATOR . $document->department->code . DIRECTORY_SEPARATOR . $document->name;
-            Storage::disk('local')->deleteDirectory($location);
-            Alert::flash($document->name . " deleted successfully");
-        }
-        return redirect()->route("dashboard.documents.index");
-    }
-
-    public function deleteFile($id)
-    {
-        $file = File::find($id);
-        $file->delete();
-        Storage::disk('local')->delete($file->location);
-
-        Alert::flash($file->name . " deleted successfully");
-
-        return redirect()->back();
-    }
-
-    public function downloadFile($id)
-    {
-        $file = File::find($id);
-        return Storage::download($file->location);
-    }
-
-    public function renameFile(FileRequest $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('local')->has($newLocation)) {
-            Alert::flash("A file with the same name already exists", "error");
-            return redirect()->back();
-        }
-        else {
-            Storage::disk('local')->copy($file->location, $newLocation);
-            Storage::disk('local')->delete($file->location);
-
-        $file->location = $newLocation;
-        $file->save();
-
-        Alert::flash($file->name . " updated successfully");
-        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 c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Controllers\Dashboard;
+
+use App\Exports\FilesExport;
+use App\Exports\FoldersExport;
+use App\Exports\UsersExport;
+use App\Http\Controllers\Controller;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\DB;
+use Maatwebsite\Excel\Concerns\WithHeadings;
+use Maatwebsite\Excel\Facades\Excel;
+
+
+class ExportExcelController extends Controller
+{
+    public function ExportUsers()
+    {
+        return Excel::download(new UsersExport(), Carbon::now()->format('d.m.Y - H:i') . ' - users.xlsx');
+
+    }
+
+    public function ExportFolders()
+    {
+        return Excel::download(new FoldersExport(), Carbon::now()->format('d.m.Y - H:i') . ' - folders.xlsx');
+
+    }
+
+    public function ExportFiles()
+    {
+        return Excel::download(new FilesExport(), Carbon::now()->format('d.m.Y - H:i') . ' - files.xlsx');
+
+    }
+}
Index: app/Http/Controllers/Dashboard/FilesController.php
===================================================================
--- app/Http/Controllers/Dashboard/FilesController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/FilesController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,105 @@
+<?php
+
+namespace App\Http\Controllers\Dashboard;
+
+use App\Helpers\Alert;
+use App\Http\Controllers\Controller;
+use App\Http\Requests\Dashboard\FileNameRequest;
+use App\Http\Requests\Dashboard\FileRequest;
+use App\Models\FileType;
+use App\Models\Folder;
+use App\Models\File;
+use App\Models\User;
+use App\Notifications\NewFileCreated;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\Notification;
+use Illuminate\Support\Facades\Storage;
+
+class FilesController extends Controller
+{
+    public function index ()
+    {
+        return view("dashboard.files.index")->with([
+            "files" => File::all(),
+            "folders" => Folder::all(),
+            "excelExt" => array("xls", "xlsx", "xls", "csv"),
+            "textExt" => array("txt", "doc", "docx"),
+            "imageExt" => array("png", "jpg", "jpeg"),
+            "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))
+        ]);
+    }
+
+    public function deleteFile($id)
+    {
+        $file = File::find($id);
+        $file->delete();
+        Storage::disk('uploads')->delete($file->location);
+
+        Alert::flash($file->name . " deleted successfully");
+
+        return redirect()->back();
+    }
+
+    public function store(FileRequest $request)
+    {
+        $file = new File();
+
+        $folder = Folder::find($request->folder);
+
+        $location = $folder->location;
+
+        $users = User::all();
+
+        if ($request->has('file_item')) {
+            foreach ($request->file_item as $file) {
+                $fileName = $folder->name . '-' . uniqid() . '.' . $file->getClientOriginalExtension();
+                $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName);
+                $newFile = new File();
+                $newFile->name = $fileName;
+                $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
+                $newFile->folder()->associate($folder);
+                $newFile->save();
+            }
+            Notification::send($users, new NewFileCreated("New files added"));
+
+            Alert::flash("New files added successfully");
+
+            return redirect()->route("dashboard.files.index");
+        }
+        else {
+            Alert::flash("No files were uploaded", "error");
+
+            return redirect()->route("dashboard.files.index");
+        }
+    }
+
+    public function downloadFile($id)
+    {
+        $file = File::find($id);
+        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 c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/FoldersController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,323 @@
+<?php
+
+namespace App\Http\Controllers\Dashboard;
+
+use App\Helpers\Alert;
+use App\Http\Requests\Dashboard\FolderRequest;
+use App\Http\Requests\Dashboard\FileNameRequest;
+use App\Models\Department;
+use App\Models\FileType;
+use App\Models\Folder;
+use App\Models\File;
+use App\Models\User;
+use App\Notifications\NewFolderCreated;
+use Carbon\Carbon;
+use Illuminate\Filesystem\Filesystem;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Notification;
+use Illuminate\Support\Facades\Storage;
+use App\Http\Controllers\Controller;
+
+class FoldersController extends Controller
+{
+    public function index(Request $request)
+    {
+        $deptName = "";
+        $deptCode = "";
+
+        if ($request->query('id')) {
+            $deptName = Department::find($request->query('id'))->getOriginal('name');
+            $deptCode = Department::find($request->query('id'))->getOriginal('code');
+            $foldersInDeptSort = Folder::with('department')->when($request->has('id'), function ($query) use ($request) {
+                $query->where('department_id', $request->query('id'));
+            });
+
+            if ($request->query('sort') == 'newest') {
+                $folders = $foldersInDeptSort->orderBy('created_at', 'desc')->paginate(12);
+            }
+            else if ($request->query('sort') == 'name') {
+                $folders = $foldersInDeptSort->orderBy('name', 'asc')->paginate(12);
+            }
+            else if($request->query('sort') == 'count'){
+                $total = $foldersInDeptSort->folder->files->count();
+                $folders = $foldersInDeptSort->orderBy($total, 'asc')->paginate(12);
+            }
+            else {
+                $folders = Folder::where('department_id', $request->query('id'))->paginate(12);
+            }
+        } else {
+            if ($request->query('sort') == 'newest') {
+                $folders = Folder::orderBy('created_at', 'desc')->paginate(12);
+            }
+            else if ($request->query('sort') == 'name') {
+                $folders = Folder::orderBy('name', 'asc')->paginate(12);
+            }
+            else if ($request->query('sort') == 'important') {
+                $folders = Folder::where('is_important', true)->paginate(12);
+            }
+            else if ($request->query('sort') == 'recent') {
+                $folders = Folder::orderBy('created_at', 'desc')->paginate(12);
+            } else if ($request->query('search')) {
+
+                $result = collect();
+                $queries = explode(" ", $request->search);
+                foreach ($queries as $query) {
+                    $result->push(Folder::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get());
+                }
+                $result = $result->flatten();
+                $folders = $result;
+            } else {
+                $folders = Folder::paginate(12);
+            }
+        }
+
+        $departments = Department::all();
+
+        $diskTotal = disk_total_space('/');
+        $diskTotalSize = $diskTotal / 1073741824;
+
+        $diskFree = disk_free_space('/');
+        $used = $diskTotal - $diskFree;
+
+        $diskUsedSize = $used / 1073741824;
+        $diskUse1 = round(100 - (($diskUsedSize / $diskTotalSize) * 100));
+        $diskUse = round(100 - ($diskUse1)) . '%';
+
+        return view("dashboard.folders.index")->with([
+            "folders" => $folders,
+            "currentUser" => auth()->user(),
+            "departments" => $departments,
+            "docsCount" => Department::withCount('folder')->get(),
+            "totalDocs" => Folder::all()->count(),
+            "countImportant" => Folder::where('is_important', true)->get()->count(),
+            "diskTotal" => $diskTotal,
+            "diskTotalSize" => $diskTotalSize,
+            "diskUse" => $diskUse,
+            "diskUsedSize" => $diskUsedSize,
+            "deptName" => $deptName,
+            "deptCode" => $deptCode,
+            "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))
+        ]);
+
+    }
+
+    public function create()
+    {
+        return view("dashboard.folders.create")->with([
+            "departments" => Department::all()
+        ]);
+    }
+
+    public function store(FolderRequest $request)
+    {
+        $folder = new Folder();
+        $user = auth()->user();
+        $department = Department::find($request->department);
+
+        $folder->user()->associate($user);
+        $folder->department()->associate($department);
+
+        $folder->arch_id = $request->arch_id;
+        $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;
+
+        if (!Storage::disk('uploads')->has($location)) {
+            Storage::disk('uploads')->makeDirectory($location);
+        }
+
+        $users = User::all();
+        Notification::send($users, new NewFolderCreated("New folder created"));
+
+        $folder->location = $location;
+
+        $folder->save();
+
+        if ($request->has('file_item')) {
+            foreach ($request->file_item as $file) {
+                $fileName = $folder->name . '-' . uniqid() . '.' . $file->getClientOriginalExtension();
+                $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName);
+                $newFile = new File();
+                $newFile->name = $fileName;
+                $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
+                $newFile->folder()->associate($folder);
+                $newFile->save();
+            }
+        }
+
+        Alert::flash("New folder created successfully");
+
+        return redirect()->route("dashboard.folders.index");
+    }
+
+    public function editShow($id)
+    {
+        return view("dashboard.folders.edit")->with([
+            "folder" => Folder::findOrFail($id),
+            "departments" => Department::all(),
+            "files" => File::where('folder_id', $id)->get(),
+            "excelExt" => array("xls", "xlsx", "xls", "csv"),
+            "textExt" => array("txt", "doc", "docx"),
+            "imageExt" => array("png", "jpg", "jpeg"),
+        ]);
+    }
+
+    public function edit(FolderRequest $request, $id)
+    {
+        $folder = Folder::findOrFail($id);
+        $files = File::where('folder_id', $id)->get();
+
+        $department = Department::find($request->department);
+
+        $folder->department()->associate($department);
+
+        $oldLocation = $folder->department->location . DIRECTORY_SEPARATOR . $folder->name;
+
+        $folder->name = $request->name;
+        $folder->arch_id = $request->arch_id;
+        $folder->note = $request->note;
+        $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;
+                    $file->save();
+                }
+            }
+        }
+
+        if ($request->has('file_item')) {
+            foreach ($request->file_item as $file) {
+                $fileName = $folder->name . '-' . uniqid() . '.' . $file->getClientOriginalExtension();
+                    $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName);
+                    $newFile = new File();
+                    $newFile->name = $fileName;
+                    $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName;
+                    $newFile->folder()->associate($folder);
+                    $newFile->save();
+            }
+        }
+
+        $folder->location = $location;
+
+        $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) {
+
+            foreach ($files as $file) {
+                $file->delete();
+            }
+            $folder->delete();
+            $location = $folder->department->location . DIRECTORY_SEPARATOR . $folder->name;
+            Storage::disk('uploads')->deleteDirectory($location);
+            Alert::flash($folder->name . " deleted successfully");
+        }
+        Alert::flash($folder->name . " is important", "error");
+        return redirect()->route("dashboard.folders.index");
+    }
+
+    public function downloadfolder(Request $request, $id)
+    {
+        $folder = Folder::find($id);
+
+        $FileSystem = new Filesystem();
+        $zip_file = Storage::disk('uploads')->path('Folder.zip');
+        $zip = new \ZipArchive();
+        $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
+        $path = Storage::disk('uploads')->path($folder->department->location . DIRECTORY_SEPARATOR . $folder->name);
+
+        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+
+        $filesInDoc = $FileSystem->allFiles($path);
+
+        if(empty(!$filesInDoc)) {
+            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') . $folder->name . '.zip';
+                return response()->download($zip_file, $zip_new_name, $headers);
+        }
+        else {
+            Alert::flash("This folder has no files", "warning");
+            return redirect()->back();
+        }
+
+    }
+
+    public function files(Request $request, $id)
+    {
+        $folder = Folder::findOrFail($id);
+        $files = File::where('folder_id', $id);
+        $deptId = $folder->department_id;
+        $folders = Folder::where('department_id', $deptId)->get();
+
+        $queries = explode(" ", $request->search);
+
+        if ($request->query('search')) {
+            $result = collect();
+
+            foreach ($queries as $query) {
+                $result->push($files->where("name", "like", "%{$query}%")->get());
+            }
+            $result = $result->flatten();
+            $files = $result;
+        }
+        else {
+            $files = File::where('folder_id', $id)->paginate(10);
+        }
+
+        return view("dashboard.folders.files")->with([
+            "folder" => $folder,
+            "departments" => Department::all(),
+            "files" => $files,
+            "excelExt" => array("xls", "xlsx", "xls", "csv"),
+            "textExt" => array("txt", "doc", "docx"),
+            "imageExt" => array("png", "jpg", "jpeg"),
+            "folders" => $folders,
+            "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))
+        ]);
+    }
+}
+
Index: app/Http/Controllers/Dashboard/IndexController.php
===================================================================
--- app/Http/Controllers/Dashboard/IndexController.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Controllers/Dashboard/IndexController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -4,4 +4,7 @@
 
 use App\Helpers\Alert;
+use App\Models\Department;
+use App\Models\Folder;
+use App\Models\File;
 use App\Models\User;
 use App\Http\Controllers\Controller;
@@ -17,4 +20,7 @@
         return view("dashboard.index")->with([
             "counters" => $counters,
+            "departments" => Department::all(),
+            "folders" => Folder::all(),
+            "files" => File::all()
         ]);
     }
Index: app/Http/Controllers/Dashboard/NotificationsController.php
===================================================================
--- app/Http/Controllers/Dashboard/NotificationsController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Controllers/Dashboard/NotificationsController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,81 @@
+<?php
+
+namespace App\Http\Controllers\Dashboard;
+
+use Carbon\Carbon;
+use App\Http\Controllers\Controller;
+
+class NotificationsController extends Controller
+{
+    public $notifications;
+    private $notificationsLimit = 10;
+
+    public function __construct() {
+        $this->middleware("auth");
+        $this->notifications = null;
+    }
+
+    public function notifications() {
+        return view("dashboard.notifications.index")->with([
+            "notifications" => $this->decode(auth()->user()->notifications, true)
+        ]);
+    }
+
+    public function getNotifications() {
+        return auth()->user()->readNotifications;
+    }
+
+    public function getUnreadNotifications() {
+        return auth()->user()->unreadNotifications;
+    }
+
+    public function markNotificationsAsRead() {
+        return auth()->user()->unreadNotifications->markAsRead();
+    }
+
+    public function showNotifications() {
+
+        $this->notifications = collect();
+
+        if($this->getUnreadNotifications()->count() == 0) {
+            $this->notifications->push($this->getNotifications()->take($this->notificationsLimit));
+            $this->notifications = $this->notifications->flatten();
+            return response()->json($this->decode($this->notifications->reverse()));
+        }
+
+        if($this->getUnreadNotifications()->count() > 10) {
+            $this->notifications->push($this->getUnreadNotifications()->take($this->notificationsLimit));
+        } else {
+            $readNotifications = $this->notificationsLimit - $this->getUnreadNotifications()->count();
+            $this->notifications->push($this->getUnreadNotifications());
+            $this->notifications->push($this->getNotifications()->take($readNotifications));
+        }
+
+        $this->notifications = $this->notifications->flatten();
+
+        return response()->json($this->decode($this->notifications->reverse()));
+    }
+
+    public function decode($notifications, $isShowOnly = false) {
+
+        $response = array();
+        $decoded = json_decode($notifications);
+
+        foreach($decoded as $notification) {
+            $isRead = empty($notification->read_at) ? false : true;
+            array_push($response, [
+                "isRead" => $isRead,
+                // "from" => $notification->data->from,
+                "url" => $notification->data->url,
+                "message" => $notification->data->message,
+                "ago" => Carbon::parse($notification->created_at)->diffForHumans(),
+            ]);
+        }
+
+        if(!$isShowOnly) {
+            $this->markNotificationsAsRead();
+        }
+
+        return $response;
+    }
+}
Index: app/Http/Controllers/Dashboard/SettingsController.php
===================================================================
--- app/Http/Controllers/Dashboard/SettingsController.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Controllers/Dashboard/SettingsController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -5,6 +5,8 @@
 use App\Helpers\Alert;
 use App\Http\Requests\Dashboard\EmailSettingsRequest;
+use App\Http\Requests\Dashboard\FileTypeRequest;
 use App\Http\Requests\Dashboard\PasswordSettingsRequest;
 use App\Http\Requests\Dashboard\UsernameSettingsRequest;
+use App\Models\FileType;
 use App\Models\User;
 use App\Http\Controllers\Controller;
@@ -19,8 +21,11 @@
     public function settings()
     {
+        $fileType = FileType::find("1");
+
         return view("dashboard.settings.index")->with([
             "user" => auth()->user(),
             "adminAndReferents" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),
-            "active_tab" => "account"
+            "active_tab" => "account",
+            "fileType" => $fileType
         ]);
     }
@@ -30,4 +35,5 @@
             $user = auth()->user();
             $user->username = $request->username;
+            $user->updated_at = Carbon::now();
             $user->save();
 
@@ -42,4 +48,5 @@
             $user = auth()->user();
             $user->password = bcrypt($request->password);
+            $user->updated_at = Carbon::now();
             $user->save();
 
@@ -58,4 +65,5 @@
         $user->security_code = $user->generateSecurityCode();
         $user->verify_token = $user->generateVerifyToken();
+        $user->updated_at = Carbon::now();
 
         $user->save();
@@ -69,3 +77,28 @@
     }
 
+
+
+    public function fileTypes(FileTypeRequest $request)
+    {
+        $fileType = FileType::find("1");
+
+        $fileType->mimes = $request->mimes;
+        $fileType->max_size = $request->max_size;
+        $fileType->user_id = auth()->id();
+        $fileType->updated_at = Carbon::now();
+
+        if(auth()->user()->hasPermission("manage_file_types")) {
+            $fileType->save();
+
+            Alert::flash("File validations updated successfully");
+
+            return redirect()->back();
+        }
+        else {
+            Alert::flash("You don't have permission to change file validations", "error");
+
+            return redirect()->back();
+        }
+    }
+
 }
Index: app/Http/Controllers/Dashboard/UsersController.php
===================================================================
--- app/Http/Controllers/Dashboard/UsersController.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Controllers/Dashboard/UsersController.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -24,5 +24,6 @@
     {
         return view("dashboard.users.index")->with([
-            "users" => User::all()
+            "users" => User::all(),
+            "roles" => Role::all(),
         ]);
     }
@@ -62,4 +63,6 @@
             $user->avatar = $avatarName;
         }
+
+        $user->created_by = auth()->user()->id;
         $user->save();
 
@@ -88,5 +91,5 @@
         $user->phone_number = $request->phone_number;
         $user->role_id = $request->userRole;
-        $user->updated_at = $request->Carbon::now();;
+        $user->updated_at = Carbon::now();
 
         if ($request->hasFile("avatar")) {
Index: app/Http/Requests/Dashboard/DocumentRequest.php
===================================================================
--- app/Http/Requests/Dashboard/DocumentRequest.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ 	(revision )
@@ -1,72 +1,0 @@
-<?php
-
-namespace App\Http\Requests\Dashboard;
-
-use App\Models\Department;
-use App\Models\Document;
-use Illuminate\Foundation\Http\FormRequest;
-
-class DocumentRequest extends FormRequest
-{
-    /**
-     * Determine if the user is authorized to make this request.
-     *
-     * @return bool
-     */
-    public function authorize()
-    {
-        if ($this->isMethod("patch")) {
-            $document = Document::find($this->route("id"));
-            return auth()->user()->hasPermission("edit_all_documents") || ($document->user->id == auth()->user()->id);
-        }
-
-        return true;
-    }
-
-    /**
-     * Get the validation rules that apply to the request.
-     *
-     * @return array
-     */
-    public function rules()
-    {
-        $rules = [
-            "arch_id" => [
-                "required",
-                function ($attribute, $value, $fail) {
-                    $arch_id = $this->request->get('arch_id');
-                    $deptId = explode('/', $arch_id)[0];
-                    $archNum = explode('/', $arch_id)[1];
-
-                    if (empty($archNum)) {
-                        $fail("Please enter documents Archive ID");
-                    }
-
-                    if ($deptId !== Department::find($this->request->get('department'))->code) {
-                        $fail("Document Archive ID field format is invalid");
-                    }
-                }
-            ],
-            "name" => "required|min:10|max:255",
-            "department" => "required|integer|exists:departments,id",
-            "description" => "required|min:30",
-        ];
-
-        if ($this->isMethod("patch")) {
-            $fileRules = [
-                "file_item.*" => "mimes:jpg,jpeg,png,pdf|max:4096"
-            ];
-        } else {
-            $fileRules = [
-                "file_item.*" => "mimes:jpg,jpeg,png,pdf|max:4096"
-            ];
-        }
-
-        $rules = array_merge(
-            $rules,
-            $fileRules,
-        );
-
-        return $rules;
-    }
-}
Index: app/Http/Requests/Dashboard/FileNameRequest.php
===================================================================
--- app/Http/Requests/Dashboard/FileNameRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Requests/Dashboard/FileNameRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests\Dashboard;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class FileNameRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            "name" => ['required', 'max:255', 'regex:/^[^.\/|]+$/', 'unique:files,name,$this->id,id']
+        ];
+    }
+}
Index: app/Http/Requests/Dashboard/FileRequest.php
===================================================================
--- app/Http/Requests/Dashboard/FileRequest.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Requests/Dashboard/FileRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -3,4 +3,7 @@
 namespace App\Http\Requests\Dashboard;
 
+use App\Helpers\Alert;
+use App\Models\FileType;
+use App\Rules\UploadCount;
 use Illuminate\Foundation\Http\FormRequest;
 
@@ -24,7 +27,29 @@
     public function rules()
     {
-        return [
-            "name" => "required|max:255|regex:/^[^.]+$/",
-        ];
+        $rules = [
+            "folder" => "required|integer|exists:folders,id",
+            ];
+
+        $mimes = FileType::find("1")->mimes;
+        $maxSize = FileType::find("1")->max_size;
+
+        if ($this->isMethod("patch")) {
+            $fileRules = [
+                "file_item.*" => "mimes:{$mimes}|max:{$maxSize}"
+            ];
+        }
+
+        else {
+            $fileRules = [
+                "file_item.*" => "mimes:{$mimes}|max:{$maxSize}"
+            ];
+        }
+
+        $rules = array_merge(
+            $rules,
+            $fileRules,
+        );
+
+        return $rules;
     }
 }
Index: app/Http/Requests/Dashboard/FileTypeRequest.php
===================================================================
--- app/Http/Requests/Dashboard/FileTypeRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Requests/Dashboard/FileTypeRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Http\Requests\Dashboard;
+
+use Illuminate\Foundation\Http\FormRequest;
+use League\Flysystem\Util\MimeType;
+use League\MimeTypeDetection\MimeTypeDetector;
+
+class FileTypeRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            "mimes" => [
+                "required",
+//                function ($attribute, $value, $fail) {
+//
+//                    try {
+//                        $mimeType = mimes;
+//                        @dd($mimeType);
+//                        $mimetypes = $guesser->guess($pubdir . $avatar);
+////                        if ($mimetypes == null) {
+////                            $validator->errors()->add('avatar', 'No valid Mime/Type');
+////                            return $validator;
+////                        }
+////                    }
+////
+////$mime= explode ('/', $mimetypes);
+////if ($mime[0] != 'image') {
+////    $validator->errors()->add('avatar', 'Not a valid image');
+////}
+//
+//                        if (empty($archNum)) {
+//                            $fail("Please enter folders Archive ID");
+//                        }
+//
+//                        if ($deptId !== Department::find($this->request->get('department'))->code) {
+//                            $fail("Folder Archive ID field format is invalid");
+//                        }
+//                    } catch (\Exception $e) {
+//                        $fail("Please enter folders Archive ID");
+//                    }
+//                }
+            ],
+            "max_size" => "required|integer",
+        ];
+    }
+}
Index: app/Http/Requests/Dashboard/FolderRequest.php
===================================================================
--- app/Http/Requests/Dashboard/FolderRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
+++ app/Http/Requests/Dashboard/FolderRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -0,0 +1,84 @@
+<?php
+
+namespace App\Http\Requests\Dashboard;
+
+use App\Models\Department;
+use App\Models\FileType;
+use App\Models\Folder;
+use Illuminate\Foundation\Http\FormRequest;
+
+class FolderRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        if ($this->isMethod("patch")) {
+            $folder = Folder::find($this->route("id"));
+            return auth()->user()->hasPermission("edit_all_folders") || ($folder->user->id == auth()->user()->id);
+        }
+
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        $rules = [
+            "arch_id" => [
+                "required",
+                "unique:folders,arch_id,$this->id,id",
+                function ($attribute, $value, $fail) {
+
+                    try {
+                        $arch_id = $this->request->get('arch_id');
+
+                        $deptId = explode('/', $arch_id)[0];
+                        $archNum = explode('/', $arch_id)[1];
+
+                        if (empty($archNum)) {
+                            $fail("Please enter folders Archive ID");
+                        }
+
+                        if ($deptId !== Department::find($this->request->get('department'))->code) {
+                            $fail("Folder Archive ID field format is invalid");
+                        }
+                    } catch (\Exception $e) {
+                        $fail("Please enter folders Archive ID");
+                    }
+                }
+            ],
+            "name" => "required|min:2|max:30",
+            "department" => "required|integer|exists:departments,id",
+        ];
+
+        $mimes = FileType::find("1")->mimes;
+        $maxSize = FileType::find("1")->max_size;
+
+        if ($this->isMethod("patch")) {
+            $fileRules = [
+                "file_item.*" => "mimes:{$mimes}|max:{$maxSize}"
+            ];
+        }
+
+        else {
+            $fileRules = [
+                "file_item.*" => "mimes:{$mimes}|max:{$maxSize}"
+            ];
+        }
+
+        $rules = array_merge(
+            $rules,
+            $fileRules,
+        );
+
+        return $rules;
+    }
+}
Index: app/Http/Requests/Dashboard/NewUserRequest.php
===================================================================
--- app/Http/Requests/Dashboard/NewUserRequest.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Requests/Dashboard/NewUserRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -29,7 +29,7 @@
             "phone_number" => "required|unique:users,phone_number",
             "email" => "required|string|email|max:50|unique:users,email",
-            "username" => "required|min:5|max:30|unique:users,username",
+            "username" => "required|alpha_dash|min:5|unique:users,username",
             "userRole" => "required|exists:roles,id",
-            "avatar" => "mimes:jpeg,png,gif|max:5000",
+            "avatar" => "image|max:5000",
         ];
     }
Index: app/Http/Requests/Dashboard/UpdateUserRequest.php
===================================================================
--- app/Http/Requests/Dashboard/UpdateUserRequest.php	(revision 6b95845bcb5cbd47d72feb8e241175b5fc16d0e0)
+++ app/Http/Requests/Dashboard/UpdateUserRequest.php	(revision c6b84df06586305606df5b76204a64cdc63b09a2)
@@ -29,5 +29,5 @@
             "phone_number" => "required|unique:users,phone_number,$this->id,id",
             "email" => "required|string|email|max:50|unique:users,email,$this->id,id",
-            "username" => "required|min:5|unique:users,username,$this->id,id",
+            "username" => "required|alpha_dash|min:5|unique:users,username,$this->id,id",
             "userRole" => "required|exists:roles,id",
             "avatar" => "mimes:jpeg,png,gif|max:5000",
