Changeset c6b84df for database


Ignore:
Timestamp:
10/21/21 23:45:59 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
4b7e2d3
Parents:
6b95845
Message:

added fileTypes controller, notifications, excel export, edited views

Location:
database
Files:
4 added
1 deleted
8 edited
2 moved

Legend:

Unmodified
Added
Removed
  • database/factories/DepartmentFactory.php

    r6b95845 rc6b84df  
    2424    public function definition()
    2525    {
    26         $location = $this->faker->unique()->numberBetween('1', '9');
    27         Storage::disk('local')->makeDirectory('Departments/' . $location);
     26        $location = $this->faker->unique()->numberBetween(1, 15);
     27        Storage::disk('uploads')->makeDirectory('Departments/' . $location);
    2828        return [
    2929            'name' => "Department" . $this->faker->unique()->firstName(),
    3030            'code' => $location,
    31             'location' => Storage::disk('local')->path('') . 'Departments' . DIRECTORY_SEPARATOR . $location,
     31            'location' => 'Departments' . DIRECTORY_SEPARATOR . $location,
    3232            'user_id' => $this->faker->numberBetween('1', '2'),
    3333            'created_at' => Carbon::now()
  • database/factories/FolderFactory.php

    r6b95845 rc6b84df  
    44
    55use App\Models\Department;
    6 use App\Models\Document;
     6use App\Models\Folder;
    77use Carbon\Carbon;
    88use Illuminate\Database\Eloquent\Factories\Factory;
    99use Illuminate\Support\Facades\Storage;
    1010
    11 class DocumentFactory extends Factory
     11class FolderFactory extends Factory
    1212{
    1313    /**
     
    1616     * @var string
    1717     */
    18     protected $model = Document::class;
     18    protected $model = Folder::class;
    1919
    2020    /**
     
    2626    {
    2727
    28         $deptID = "5";
     28        $deptId = $this->faker->numberBetween('1', '15');
     29        $deptCode = Department::find($deptId)->code;
    2930        $name = $this->faker->unique()->firstName();
    30         Storage::disk('local')->makeDirectory('Departments' . DIRECTORY_SEPARATOR . $deptID . DIRECTORY_SEPARATOR . $name);
     31
     32        $location = 'Departments' . DIRECTORY_SEPARATOR . $deptCode . DIRECTORY_SEPARATOR . $name;
     33        Storage::disk('uploads')->makeDirectory($location);
     34
    3135
    3236        return [
    33             'arch_id' => $deptID . "/" . $this->faker->unique()->randomNumber(),
     37            'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(),
    3438            'name' => $name,
    35             'description' => $this->faker->realText(),
     39            'note' => $this->faker->realText(),
     40            'location' => $location,
    3641            'user_id' => $this->faker->numberBetween('1', '2'),
    37             'department_id' => $deptID,
     42            'department_id' => $deptId,
    3843            'is_important' => $this->faker->boolean,
    3944            'created_at' => $this->faker->dateTime()
    4045        ];
    41 
    4246    }
    4347}
  • database/migrations/2021_09_27_171107_create_users_table.php

    r6b95845 rc6b84df  
    2020            $table->string('surname');
    2121            $table->string('username')->unique();
    22             $table->string('password');
    2322            $table->string('email')->unique();
    2423            $table->string('phone_number')->unique();
     
    3029            $table->boolean('is_confirmed')->default(false);
    3130            $table->boolean('is_forgot_password')->default(false);
     31            $table->integer("created_by")->unsigned();
    3232            $table->integer('security_code')->nullable();
    3333            $table->string('verify_token')->nullable();
    34             $table->integer("created_by")->unsigned();
     34            $table->string('password');
    3535            $table->rememberToken();
    3636            $table->timestamps();
  • database/migrations/2021_10_06_103305_create_folders_table.php

    r6b95845 rc6b84df  
    55use Illuminate\Support\Facades\Schema;
    66
    7 class CreateDocumentsTable extends Migration
     7class CreateFoldersTable extends Migration
    88{
    99    /**
     
    1414    public function up()
    1515    {
    16         Schema::create('documents', function (Blueprint $table) {
     16        Schema::create('folders', function (Blueprint $table) {
    1717            $table->bigIncrements('id');
    1818            $table->string("arch_id")->unique();
    1919            $table->string("name");
    20             $table->text("description");
     20            $table->text("note")->nullable();
     21            $table->string("location");
    2122            $table->integer("user_id")->unsigned();
    2223            $table->integer("department_id")->unsigned();
    23             $table->boolean("is_important")->default(true);
     24            $table->boolean("is_important")->default(false);
    2425            $table->timestamps();
    2526
     
    3637    public function down()
    3738    {
    38         Schema::dropIfExists('documents');
     39        Schema::dropIfExists('folders');
    3940    }
    4041}
  • database/migrations/2021_10_10_103309_create_files_table.php

    r6b95845 rc6b84df  
    1616        Schema::create('files', function (Blueprint $table) {
    1717            $table->bigIncrements('id');
    18             $table->bigInteger('document_id')->unsigned();
     18            $table->bigInteger('folder_id')->unsigned();
    1919            $table->string("name");
    2020            $table->string("location");
    21             $table->foreign("document_id")->references("id")->on("documents");
     21            $table->foreign("folder_id")->references("id")->on("folders");
    2222            $table->timestamps();
    2323        });
  • database/seeders/DatabaseSeeder.php

    r6b95845 rc6b84df  
    1919        $this->call(UsersTableSeeder::class);
    2020        $this->call(DepartmentsTableSeeder::class);
    21         //$this->call(DocumentsTableSeeder::class);
     21        $this->call(FileTypeSeeder::class);
     22        $this->call(FoldersTableSeeder::class);
    2223    }
    2324}
  • database/seeders/DepartmentsTableSeeder.php

    r6b95845 rc6b84df  
    1616    public function run()
    1717    {
    18         Department::factory()->count(8)->create();
     18        Department::factory()->count(15)->create();
    1919    }
    2020}
  • database/seeders/PermissionsTableSeeder.php

    r6b95845 rc6b84df  
    2020            ["name" => "manage_all_users"],             // Access all users to manage
    2121            ["name" => "manage_all_departments"],       // Access all departments to manage
    22             ["name" => "manage_all_documents"],         // Access all documents to manage
     22            ["name" => "manage_all_folders"],       // Access all folders to manage
    2323            ["name" => "view_all_departments"],         // Access all departments to view
    24             ["name" => "view_all_documents"],       // Access all documents to view
    25             ["name" => "edit_all_documents"],           // Edit all documents
    26             ["name" => "edit_document"],                    // Edit your document/s
    27             ["name" => "delete_all_documents"],         // Delete all document/s
    28             ["name" => "delete_document"],              // Delete your document/s
    29             ["name" => "manage_file_types"],    // Access all file_types to manage
     24            ["name" => "view_all_folders"],         // Access all folders to view
     25            ["name" => "edit_all_folders"],             // Edit all folders
     26            ["name" => "edit_folder"],                  // Edit your folder/s
     27            ["name" => "delete_all_folders"],       // Delete all folder/s
     28            ["name" => "delete_folder"],                // Delete your folder/s
     29            ["name" => "manage_all_files"],         // Access all files
     30            ["name" => "manage_file_types"],        // Access file types
    3031        ]);
    3132    }
  • database/seeders/RolesPermissionsTableSeeder.php

    r6b95845 rc6b84df  
    2727            ["role_id" => 1, "permission_id" => 10],
    2828            ["role_id" => 1, "permission_id" => 11],
     29            ["role_id" => 1, "permission_id" => 12],
    2930
    3031            // Referent
  • database/seeders/RolesTableSeeder.php

    r6b95845 rc6b84df  
    1515    {
    1616        \DB::table('roles')->insert([
    17             ["name" => "Admin"], // Have access to all users(managing users), departments, documents etc
    18             ["name" => "Referent"], // Have access to manage and view all departments, documents etc
    19             ["name" => "Viewer"], // Have access to view all departments, documents etc
     17            ["name" => "Admin"], // Have access to all users(managing users), departments, folders etc
     18            ["name" => "Referent"], // Have access to manage and view all departments, folders etc
     19            ["name" => "Viewer"], // Have access to view all departments, folders etc
    2020        ]);
    2121    }
Note: See TracChangeset for help on using the changeset viewer.