Index: app/Http/Controllers/Dashboard/DepartmentsController.php
===================================================================
--- app/Http/Controllers/Dashboard/DepartmentsController.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Controllers/Dashboard/DepartmentsController.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -7,5 +7,7 @@
 use App\Http\Requests\Dashboard\UpdateDepartmentRequest;
 use App\Models\Department;
+use App\Models\Document;
 use App\Models\User;
+use Carbon\Carbon;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Controller;
@@ -25,11 +27,4 @@
     {
         return view("dashboard.departments.create");
-    }
-
-    public function editShow($id)
-    {
-        return view("dashboard.departments.edit")->with([
-            "department" => Department::findOrFail($id)
-        ]);
     }
 
@@ -55,4 +50,11 @@
     }
 
+    public function editShow($id)
+    {
+        return view("dashboard.departments.edit")->with([
+            "department" => Department::findOrFail($id)
+        ]);
+    }
+
     public function edit(UpdateDepartmentRequest $request, $id)
     {
@@ -63,4 +65,5 @@
         $department->name = $request->name;
         $department->code = $request->code;
+        $department->updated_at = Carbon::now();;
 
         $path = '/Departments/' . $request->code;
@@ -83,11 +86,18 @@
     }
 
-    public function destroy(Request $request, $id)
+    public function destroy($id)
     {
         $department = Department::find($id);
+        //$department->delete();
+        $documents = $department->document()->count();
 
-        $department->delete();
+        if($documents > 0){
+            Alert::flash($department->name . " has " . $documents . " document/s associated", "error");
+        }
+        else {
+            $department->delete();
 
-        Alert::flash($department->name . " deleted successfully");
+            Alert::flash($department->name . " deleted successfully");
+        }
 
         return redirect()->route("dashboard.departments.index");
Index: app/Http/Controllers/Dashboard/DocumentsController.php
===================================================================
--- app/Http/Controllers/Dashboard/DocumentsController.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Controllers/Dashboard/DocumentsController.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -8,30 +8,32 @@
 use App\Models\Document;
 use App\Models\File;
-use App\Models\Files;
-use App\Models\User;
-use App\Notifications\NewDocumentCreated;
 use App\Services\UploadService;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Storage;
-use Mews\Purifier\Facades\Purifier;
 use App\Http\Controllers\Controller;
-use Illuminate\Support\Facades\Notification;
 
 class DocumentsController extends Controller
 {
-    public function index()
+    public function index(Request $request)
     {
-        if (auth()->user()->hasPermission("manage_all_documents"))
+        if($request->department) {
+            $documents = Document::with('department')->where('department', function ($query) {
+                $query->where('id', $request->department)->get();
+            });
+        }
+        else{
             $documents = Document::all();
-        else
-            $documents = Document::where("user_id", auth()->user()->id)->get();
+        }
+
+        $departments = Department::all();
 
         return view("dashboard.documents.index")->with([
             "documents" => $documents,
             "currentUser" => auth()->user(),
-            "departments" => Department::all(),
+            "departments" => $departments,
             "docsCount" => Department::withCount('document')->get(),
             'totalDocs' => Document::all()->count()
         ]);
+
     }
 
@@ -66,4 +68,5 @@
         $document->arch_id = $request->arch_id;
         $document->description = $request->description;
+        $document->updated_at = $request->Carbon::now();;
 
         $document->save();
@@ -108,18 +111,3 @@
     }
 
-    public function getDocumentsInDepartment($id)
-    {
-        $documents = Department::findOrFail($id)->document()->get();
-        $department = Department::findOrFail($id);
-
-        return view('dashboard.documents.department')
-            ->with([
-                'documents' => $documents,
-                'departments' => Department::all(),
-                'totalDocs' => Document::all()->count(),
-                'department' => $department
-
-        ]);
-    }
-
 }
Index: app/Http/Controllers/Dashboard/NotificationsController.php
===================================================================
--- app/Http/Controllers/Dashboard/NotificationsController.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ 	(revision )
@@ -1,81 +1,0 @@
-<?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 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Controllers/Dashboard/SettingsController.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -3,27 +3,11 @@
 namespace App\Http\Controllers\Dashboard;
 
-use App\Helpers\Alert;
 use App\Http\Requests\Dashboard\EmailSettingsRequest;
-use App\Http\Requests\Dashboard\NewUserRequest;
 use App\Http\Requests\Dashboard\PasswordSettingsRequest;
-use App\Http\Requests\Dashboard\PhotosSettingsRequest;
-use App\Http\Requests\Dashboard\SocialLinksSettingsRequest;
-use App\Http\Requests\Dashboard\UpdateUserData;
-use App\Http\Requests\Dashboard\UpdateUserRequest;
 use App\Http\Requests\Dashboard\UsernameSettingsRequest;
-use App\Http\Requests\Dashboard\UserProfileSettingsRequest;
-use App\Models\Post;
-use App\Models\Role;
 use App\Models\User;
-use App\Models\UserProfile;
-use Illuminate\Support\Str;
-use Illuminate\Http\Request;
 use App\Http\Controllers\Controller;
-use Illuminate\Support\Facades\File;
-use Illuminate\Support\Facades\Hash;
 use App\Notifications\VerifyNewEmail;
-use Illuminate\Support\Facades\Storage;
-use Propaganistas\LaravelPhone\PhoneNumber;
-use Propaganistas\LaravelIntl\Facades\Country;
+use Carbon\Carbon;
 
 class SettingsController extends Controller
@@ -33,5 +17,5 @@
         return view("dashboard.settings.index")->with([
             "user" => auth()->user(),
-            "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get()
+            "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),
         ]);
     }
@@ -39,12 +23,17 @@
     public function updateUsername(UsernameSettingsRequest $request)
     {
-        $user = auth()->user();
-        $user->username = $request->username;
-        $user->save();
-
-        auth()->logout();
-        session()->flush();
-
-        return redirect()->route("auth.loginShow");
+//        if($request->validated()){
+//        $user = auth()->user();
+//        $user->username = $request->username;
+//        $user->save();
+//
+//        auth()->logout();
+//        session()->flush();
+//
+//        return redirect()->route("auth.loginShow");
+//        }
+//        else {
+            return back()->withInput(['tab'=>'security']);
+       // }
     }
 
Index: app/Http/Controllers/Dashboard/UsersController.php
===================================================================
--- app/Http/Controllers/Dashboard/UsersController.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Controllers/Dashboard/UsersController.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -8,4 +8,5 @@
 use App\Http\Requests\Dashboard\UpdateUserRequest;
 use App\Models\Avatar;
+use Carbon\Carbon;
 use Illuminate\Support\Facades\File;
 use App\Models\Role;
@@ -41,5 +42,5 @@
         $user->surname = $request->surname;
         $user->email = $request->email;
-        $user->mobile_number = $request->mobile_number;
+        $user->phone_number = $request->phone_number;
         $user->username = $request->username;
         $user->password = $user->generateTemporaryPassword();
@@ -85,6 +86,7 @@
         $user->username = $request->username;
         $user->email = $request->email;
-        $user->mobile_number = $request->mobile_number;
+        $user->phone_number = $request->phone_number;
         $user->role_id = $request->userRole;
+        $user->updated_at = $request->Carbon::now();;
 
         if ($request->hasFile("avatar")) {
@@ -152,5 +154,5 @@
         $user->name = $request->name;
         $user->surname = $request->surname;
-        $user->mobile_number = $request->mobile_number;
+        $user->phone_number = $request->phone_number;
 
         if ($request->hasFile("avatar")) {
Index: app/Http/Requests/Dashboard/DocumentRequest.php
===================================================================
--- app/Http/Requests/Dashboard/DocumentRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/DocumentRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -4,4 +4,5 @@
 
 use App\Models\Document;
+use App\Models\FileType;
 use Illuminate\Foundation\Http\FormRequest;
 
@@ -30,4 +31,5 @@
     public function rules()
     {
+
         $rules = [
             "arch_id" => "required|min:10|max:255",
@@ -40,5 +42,5 @@
             $fileRules = [
                 "file_item.*" => "mimes:jpg,jpeg,png|max:4096"
-            ];
+                ];
         } else {
             $fileRules = [
Index: app/Http/Requests/Dashboard/EmailSettingsRequest.php
===================================================================
--- app/Http/Requests/Dashboard/EmailSettingsRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/EmailSettingsRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,5 +25,5 @@
     {
         return [
-            "email" => "required|string|email|max:255|unique:users,email,$this->id,id",
+            "email" => "required|string|email|max:50|unique:users,email,$this->id,id",
         ];
     }
Index: app/Http/Requests/Dashboard/NewDepartmentRequest.php
===================================================================
--- app/Http/Requests/Dashboard/NewDepartmentRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/NewDepartmentRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,5 +25,5 @@
     {
         return [
-        "name" => "required|min:2|max:25|unique:departments,name",
+        "name" => "required|min:2|max:30|unique:departments,name",
         "code" => "required|min:2|max:10|unique:departments,code"
         ];
Index: app/Http/Requests/Dashboard/NewUserRequest.php
===================================================================
--- app/Http/Requests/Dashboard/NewUserRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/NewUserRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,9 +25,9 @@
     {
         return [
-            "name" => "required|alpha|min:2|max:255",
-            "surname" => "required|alpha|min:2|max:255",
-            "mobile_number" => "required|unique:users,mobile_number",
-            "email" => "required|string|email|max:255|unique:users,email",
-            "username" => "required|min:8|unique:users,username",
+            "name" => "required|alpha|min:2|max:30",
+            "surname" => "required|alpha|min:2|max:30",
+            "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",
             "userRole" => "required|exists:roles,id",
             "avatar" => "mimes:jpeg,png,gif|max:5000",
Index: app/Http/Requests/Dashboard/PasswordSettingsRequest.php
===================================================================
--- app/Http/Requests/Dashboard/PasswordSettingsRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/PasswordSettingsRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -34,5 +34,5 @@
                 }
             ],
-            "password" => "required|string|confirmed|min:8",
+            "password" => "required|string|confirmed|min:6",
         ];
     }
Index: app/Http/Requests/Dashboard/UpdateDepartmentRequest.php
===================================================================
--- app/Http/Requests/Dashboard/UpdateDepartmentRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/UpdateDepartmentRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,6 +25,6 @@
     {
         return [
-            "name" => "required|min:2|max:25|unique:departments,name,$this->id,id",
-            "code" => "required|min:2|max:10|unique:departments,code,$this->id,id"
+            "name" => "required|min:2|max:30|unique:departments,name,$this->id,id",
+            "code" => "required|min:2|max:30|unique:departments,code,$this->id,id"
         ];
     }
Index: app/Http/Requests/Dashboard/UpdateUserData.php
===================================================================
--- app/Http/Requests/Dashboard/UpdateUserData.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/UpdateUserData.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,7 +25,7 @@
     {
         return [
-            "name" => "required|alpha|min:2|max:255",
-            "surname" => "required|alpha|min:2|max:255",
-            "mobile_number" => "required|unique:users,mobile_number,$this->id,id",
+            "name" => "required|alpha|min:2|max:30",
+            "surname" => "required|alpha|min:2|max:30",
+            "phone_number" => "required|unique:users,phone_number,$this->id,id",
             "avatar" => "mimes:jpeg,png,gif|max:5000",
         ];
Index: app/Http/Requests/Dashboard/UpdateUserRequest.php
===================================================================
--- app/Http/Requests/Dashboard/UpdateUserRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/UpdateUserRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,9 +25,9 @@
     {
         return [
-            "name" => "required|alpha|min:2|max:255",
-            "surname" => "required|alpha|min:2|max:255",
-            "mobile_number" => "required|unique:users,mobile_number,$this->id,id",
-            "email" => "required|string|email|max:255|unique:users,email,$this->id,id",
-            "username" => "required|min:8|unique:users,username,$this->id,id",
+            "name" => "required|alpha|min:2|max:30",
+            "surname" => "required|alpha|min:2|max:30",
+            "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",
             "userRole" => "required|exists:roles,id",
             "avatar" => "mimes:jpeg,png,gif|max:5000",
Index: app/Http/Requests/Dashboard/UsernameSettingsRequest.php
===================================================================
--- app/Http/Requests/Dashboard/UsernameSettingsRequest.php	(revision 120759b41a3ce01c1ab16d5c512103522ae5568f)
+++ app/Http/Requests/Dashboard/UsernameSettingsRequest.php	(revision d795fa6d6f9dce899a9ce38b85983b77c28a7e19)
@@ -25,5 +25,5 @@
     {
         return [
-            "username" => "required|alpha_dash|min:8|unique:users,username,$this->id,id"
+            "username" => "required|alpha_dash|min:5|unique:users,username,$this->id,id"
         ];
     }
