Changeset 4b7e2d3 for database


Ignore:
Timestamp:
10/23/21 04:03:46 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
b39afb5
Parents:
c6b84df
Message:

bug fixes, edited export, added fileSeeder for DB testing

Location:
database
Files:
2 added
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • database/factories/DepartmentFactory.php

    rc6b84df r4b7e2d3  
    44
    55use App\Models\Department;
     6use App\Models\Folder;
    67use Carbon\Carbon;
    78use Illuminate\Database\Eloquent\Factories\Factory;
    89use Illuminate\Support\Facades\Storage;
     10use function Sodium\increment;
    911
    1012class DepartmentFactory extends Factory
     
    2426    public function definition()
    2527    {
    26         $location = $this->faker->unique()->numberBetween(1, 15);
     28        $location = $this->faker->unique()->numberBetween(10, 25);
    2729        Storage::disk('uploads')->makeDirectory('Departments/' . $location);
    2830        return [
    29             'name' => "Department" . $this->faker->unique()->firstName(),
     31            'name' => "Department" . ' ' . $this->faker->unique()->firstName(),
    3032            'code' => $location,
    3133            'location' => 'Departments' . DIRECTORY_SEPARATOR . $location,
    32             'user_id' => $this->faker->numberBetween('1', '2'),
    33             'created_at' => Carbon::now()
     34            'no_of_folders' => 0,
     35            'user_id' => "1",
     36            'created_at' => $this->faker->dateTime()
    3437        ];
    3538    }
  • database/factories/FolderFactory.php

    rc6b84df r4b7e2d3  
    66use App\Models\Folder;
    77use Carbon\Carbon;
     8use Faker\Provider\DateTime;
    89use Illuminate\Database\Eloquent\Factories\Factory;
    910use Illuminate\Support\Facades\Storage;
     
    2728
    2829        $deptId = $this->faker->numberBetween('1', '15');
     30
    2931        $deptCode = Department::find($deptId)->code;
    3032        $name = $this->faker->unique()->firstName();
     
    3335        Storage::disk('uploads')->makeDirectory($location);
    3436
    35 
    3637        return [
    3738            'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(),
    3839            'name' => $name,
    39             'note' => $this->faker->realText(),
     40            'note' => "This a note field",
    4041            'location' => $location,
    4142            'user_id' => $this->faker->numberBetween('1', '2'),
  • database/factories/UserFactory.php

    rc6b84df r4b7e2d3  
    2626            'name' => $this->faker->firstName(),
    2727            'surname' => $this->faker->lastName(),
    28             'username' => $this->faker->userName(),
     28            'username' => $this->faker->unique()->userName(),
    2929            'password' => $this->faker->password(),
    30             'email' => $this->faker->email(),
     30            'email' => $this->faker->unique()->email(),
    3131            'phone_number' => $this->faker->phoneNumber(),
    3232            'role_id' => $this->faker->numberBetween(1, 2),
     
    3535            'is_forgot_password' => $this->faker->boolean,
    3636            'created_by' => "1",
    37             'created_at' => Carbon::now()
     37            'created_at' => now()
    3838        ];
    3939    }
  • database/migrations/2021_09_29_121244_create_departments_table.php

    rc6b84df r4b7e2d3  
    1616        Schema::create('departments', function (Blueprint $table) {
    1717            $table->increments('id');
    18             $table->integer("user_id")->unsigned();
    1918            $table->string("name");
    2019            $table->string("code");
     20            $table->integer("user_id")->unsigned();
    2121            $table->string("location");
     22            $table->integer("no_of_folders")->default(0);
    2223            $table->timestamps();
    2324
  • database/migrations/2021_10_06_103305_create_folders_table.php

    rc6b84df r4b7e2d3  
    2020            $table->text("note")->nullable();
    2121            $table->string("location");
     22            $table->integer("no_of_files")->default(0);
    2223            $table->integer("user_id")->unsigned();
    2324            $table->integer("department_id")->unsigned();
  • database/migrations/2021_10_21_144552_create_file_types_table.php

    rc6b84df r4b7e2d3  
    1616        Schema::create('file_types', function (Blueprint $table) {
    1717            $table->increments('id');
    18             $table->string("mimes")->default('mimes:');
     18            $table->string("mimes")->default('jpg,jpeg,png,pdf,docx,xls,xlsx,txt,ppt,pptx');
    1919            $table->integer("max_size");
    2020            $table->integer("user_id")->unsigned();
  • database/seeders/DatabaseSeeder.php

    rc6b84df r4b7e2d3  
    1919        $this->call(UsersTableSeeder::class);
    2020        $this->call(DepartmentsTableSeeder::class);
    21         $this->call(FileTypeSeeder::class);
     21        $this->call(FileTypesTableSeeder::class);
    2222        $this->call(FoldersTableSeeder::class);
     23        $this->call(FilesTableSeeder::class);
    2324    }
    2425}
  • database/seeders/DepartmentsTableSeeder.php

    rc6b84df r4b7e2d3  
    44
    55use App\Models\Department;
     6use App\Models\Folder;
     7use App\Models\User;
    68use Carbon\Carbon;
    79use Illuminate\Database\Seeder;
  • database/seeders/FileTypesTableSeeder.php

    rc6b84df r4b7e2d3  
    66use Illuminate\Database\Seeder;
    77
    8 class FileTypeSeeder extends Seeder
     8class FileTypesTableSeeder extends Seeder
    99{
    1010    /**
     
    1616    {
    1717        \DB::table("file_types")->insert([
    18             "mimes" => "mimes:jpg,jpeg,png,pdf,docx,xls,xlsx,txt,ppt,pptx",
     18            "mimes" => "jpg,jpeg,png,pdf,docx,xls,xlsx,txt,ppt,pptx",
    1919            "max_size" => "5000",
    2020            "user_id" => "1",
  • database/seeders/FoldersTableSeeder.php

    rc6b84df r4b7e2d3  
    33namespace Database\Seeders;
    44
     5use App\Models\Department;
    56use App\Models\Folder;
    67use Carbon\Carbon;
     
    1617    public function run()
    1718    {
    18         Folder::factory()->count(300)->create();
     19        Folder::factory()->count(500)->create();
     20        $folders = Folder::all();
     21
     22        foreach ($folders as $folder) {
     23            $folder->department()->increment('no_of_folders');
     24        }
    1925    }
    2026}
  • database/seeders/UsersTableSeeder.php

    rc6b84df r4b7e2d3  
    2727            "is_confirmed" => true,
    2828            "created_by" => "1",
    29             "created_at" => Carbon::now()
     29            "created_at" => now()
    3030        ]);
    3131
    32         User::factory()->count(20)->create();
     32        User::factory()->count(50)->create();
    3333
    3434    }
Note: See TracChangeset for help on using the changeset viewer.