Index: database/factories/DepartmentFactory.php
===================================================================
--- database/factories/DepartmentFactory.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
+++ database/factories/DepartmentFactory.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -0,0 +1,31 @@
+<?php
+
+namespace Database\Factories;
+
+use App\Models\Department;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class DepartmentFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Department::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'name' => $this->faker->name(),
+            'code' => $this->faker->unique()->numerify(),
+            'location' => $this->faker->unique()->name(),
+            'user_id' => "1",
+        ];
+    }
+}
Index: database/factories/UserFactory.php
===================================================================
--- database/factories/UserFactory.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ 	(revision )
@@ -1,47 +1,0 @@
-<?php
-
-namespace Database\Factories;
-
-use App\Models\User;
-use Illuminate\Database\Eloquent\Factories\Factory;
-use Illuminate\Support\Str;
-
-class UserFactory extends Factory
-{
-    /**
-     * The name of the factory's corresponding model.
-     *
-     * @var string
-     */
-    protected $model = User::class;
-
-    /**
-     * Define the model's default state.
-     *
-     * @return array
-     */
-    public function definition()
-    {
-        return [
-            'name' => $this->faker->name(),
-            'email' => $this->faker->unique()->safeEmail(),
-            'email_verified_at' => now(),
-            'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
-            'remember_token' => Str::random(10),
-        ];
-    }
-
-    /**
-     * Indicate that the model's email address should be unverified.
-     *
-     * @return \Illuminate\Database\Eloquent\Factories\Factory
-     */
-    public function unverified()
-    {
-        return $this->state(function (array $attributes) {
-            return [
-                'email_verified_at' => null,
-            ];
-        });
-    }
-}
Index: database/migrations/2021_09_27_171107_create_users_table.php
===================================================================
--- database/migrations/2021_09_27_171107_create_users_table.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/migrations/2021_09_27_171107_create_users_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -23,4 +23,5 @@
             $table->string('email')->unique();
             $table->string('mobile_number')->unique();
+            $table->string('avatar')->nullable();
             $table->integer('role_id')->unsigned();
             $table->foreign("role_id")->references("id")->on("roles");
Index: database/migrations/2021_09_29_121244_create_departments_table.php
===================================================================
--- database/migrations/2021_09_29_121244_create_departments_table.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/migrations/2021_09_29_121244_create_departments_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -19,4 +19,5 @@
             $table->string("name");
             $table->string("code");
+            $table->string("location");
             $table->timestamps();
 
Index: database/migrations/2021_10_06_103305_create_documents_table.php
===================================================================
--- database/migrations/2021_10_06_103305_create_documents_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
+++ database/migrations/2021_10_06_103305_create_documents_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateDocumentsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('documents', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string("arch_id")->unique();
+            $table->string("name");
+            $table->text("description");
+            $table->boolean("is_active")->default(false);
+            $table->integer("user_id")->unsigned();
+            $table->integer("department_id")->unsigned();
+            $table->timestamps();
+
+            $table->foreign("user_id")->references("id")->on("users")->onDelete("cascade")->onUpdate("cascade");
+            $table->foreign("department_id")->references("id")->on("departments")->onDelete("cascade")->onUpdate("cascade");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('documents');
+    }
+}
Index: database/migrations/2021_10_07_131654_create_add_last_seen_to_users_table.php
===================================================================
--- database/migrations/2021_10_07_131654_create_add_last_seen_to_users_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
+++ database/migrations/2021_10_07_131654_create_add_last_seen_to_users_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateAddLastSeenToUsersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->timestamp('last_seen')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->timestamp('last_seen')->nullable();
+        });
+    }
+}
Index: database/migrations/2021_10_10_103309_create_files_table.php
===================================================================
--- database/migrations/2021_10_10_103309_create_files_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
+++ database/migrations/2021_10_10_103309_create_files_table.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateFilesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('files', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->bigInteger('document_id')->unsigned()->nullable();
+            $table->string("link");
+            $table->foreign("document_id")->references("id")->on("documents");
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('files');
+    }
+}
Index: database/seeders/DatabaseSeeder.php
===================================================================
--- database/seeders/DatabaseSeeder.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/seeders/DatabaseSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -19,4 +19,5 @@
         $this->call(UsersTableSeeder::class);
         $this->call(DepartmentsTableSeeder::class);
+        $this->call(DocumentsTableSeeder::class);
     }
 }
Index: database/seeders/DepartmentsTableSeeder.php
===================================================================
--- database/seeders/DepartmentsTableSeeder.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/seeders/DepartmentsTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -3,4 +3,5 @@
 namespace Database\Seeders;
 
+use App\Models\Department;
 use Carbon\Carbon;
 use Illuminate\Database\Seeder;
@@ -15,24 +16,29 @@
     public function run()
     {
-        \DB::table('departments')->insert([
-            [
-                "name" => "HR department",
-                "code" => "14",
-                "user_id" => "1",
-                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
-            ],
-            [
-                "name" => "IT department",
-                "code" => "01",
-                "user_id" => "1",
-                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
-            ],
-            [
-                "name" => "Business department",
-                "code" => "12",
-                "user_id" => "1",
-                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
-            ],
-        ]);
+//        \DB::table('departments')->insert([
+//            [
+//                "name" => "HR department",
+//                "code" => "14",
+//                "location" => "C:\laragon\www\SaveSpace\storage/Departments/14",
+//                "user_id" => "1",
+//                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+//            ],
+//            [
+//                "name" => "IT department",
+//                "code" => "01",
+//                "location" => "C:\laragon\www\SaveSpace\storage/Departments/01",
+//                "user_id" => "1",
+//                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+//            ],
+//            [
+//                "name" => "Business department",
+//                "code" => "12",
+//                "location" => "C:\laragon\www\SaveSpace\storage/Departments/12",
+//                "user_id" => "1",
+//                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+//            ],
+//        ]);
+
+        Department::factory()->count(50)->create();
     }
 }
Index: database/seeders/DocumentsTableSeeder.php
===================================================================
--- database/seeders/DocumentsTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
+++ database/seeders/DocumentsTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -0,0 +1,119 @@
+<?php
+
+namespace Database\Seeders;
+
+use Carbon\Carbon;
+use Illuminate\Database\Seeder;
+
+class DocumentsTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        \DB::table('documents')->insert([
+            [
+                "name" => "Document test",
+                "arch_id" => "HR150",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document tests",
+                "arch_id" => "HR1505",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "2",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR15033",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document testasd",
+                "arch_id" => "HR150124",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "3",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR1501421",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR150213",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR150ad",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "2",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR150234",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "3",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR15012321",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR15021312",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+            [
+                "name" => "Document test",
+                "arch_id" => "HR15312430",
+                "description" => "hahahah ah aha hshdash dhawud hwa",
+                "user_id" => "1",
+                "department_id" => "1",
+                "is_active" => "1",
+                "created_at" => Carbon::now()->format('Y-m-d H:i:s'),
+            ],
+        ]);
+    }
+}
Index: database/seeders/PermissionsTableSeeder.php
===================================================================
--- database/seeders/PermissionsTableSeeder.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/seeders/PermissionsTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -18,6 +18,13 @@
         \DB::table('permissions')->insert([
             ["name" => "create_user"], 				// Create new user
-            ["name" => "access_all_users"], 		// Access to all users to manage
-            ["name" => "access_all_departments"], 		// Access to all departments to manage
+            ["name" => "manage_all_users"], 		// Access all users to manage
+            ["name" => "manage_all_departments"], 	// Access all departments to manage
+            ["name" => "manage_all_documents"], 	// Access all documents to manage
+            ["name" => "view_all_departments"], 	// Access all departments to view
+            ["name" => "view_all_documents"], 	    // Access all documents to view
+            ["name" => "edit_all_documents"], 		// Edit all documents
+            ["name" => "edit_document"], 		    // Edit your document/s
+            ["name" => "delete_all_documents"], 	// Delete all document/s
+            ["name" => "delete_document"], 	        // Delete your document/s
         ]);
     }
Index: database/seeders/RolesPermissionsTableSeeder.php
===================================================================
--- database/seeders/RolesPermissionsTableSeeder.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/seeders/RolesPermissionsTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -19,7 +19,25 @@
             ["role_id" => 1, "permission_id" => 2],
             ["role_id" => 1, "permission_id" => 3],
+            ["role_id" => 1, "permission_id" => 4],
+            ["role_id" => 1, "permission_id" => 5],
+            ["role_id" => 1, "permission_id" => 6],
+            ["role_id" => 1, "permission_id" => 7],
+            ["role_id" => 1, "permission_id" => 8],
+            ["role_id" => 1, "permission_id" => 9],
+            ["role_id" => 1, "permission_id" => 10],
 
             // Referent
-            ["role_id" => 2, "permission_id" => 3]
+            ["role_id" => 2, "permission_id" => 3],
+            ["role_id" => 2, "permission_id" => 4],
+            ["role_id" => 2, "permission_id" => 5],
+            ["role_id" => 2, "permission_id" => 6],
+            ["role_id" => 2, "permission_id" => 7],
+            ["role_id" => 2, "permission_id" => 8],
+            ["role_id" => 2, "permission_id" => 9],
+            ["role_id" => 2, "permission_id" => 10],
+
+            // Viewer
+            ["role_id" => 3, "permission_id" => 5],
+            ["role_id" => 3, "permission_id" => 6],
         ]);
     }
Index: database/seeders/RolesTableSeeder.php
===================================================================
--- database/seeders/RolesTableSeeder.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/seeders/RolesTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -16,5 +16,6 @@
         \DB::table('roles')->insert([
             ["name" => "Admin"], // Have access to all users(managing users), departments, documents etc
-            ["name" => "Referent"], // Have access to all departments, documents etc
+            ["name" => "Referent"], // Have access to manage and view all departments, documents etc
+            ["name" => "Viewer"], // Have access to view all departments, documents etc
         ]);
     }
Index: database/seeders/UsersTableSeeder.php
===================================================================
--- database/seeders/UsersTableSeeder.php	(revision 194a35967c638db611da70bbf868d51cd9124ed2)
+++ database/seeders/UsersTableSeeder.php	(revision 24a616f69ea5bcfc52f7d556c82a951a28dd130a)
@@ -41,5 +41,4 @@
         ]);
 
-        //factory(App\Models\User::class, 50)->create();
     }
 }
