- Timestamp:
- 10/23/21 04:03:46 (3 years ago)
- Branches:
- develop, master
- Children:
- b39afb5
- Parents:
- c6b84df
- Location:
- database
- Files:
-
- 2 added
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
database/factories/DepartmentFactory.php
rc6b84df r4b7e2d3 4 4 5 5 use App\Models\Department; 6 use App\Models\Folder; 6 7 use Carbon\Carbon; 7 8 use Illuminate\Database\Eloquent\Factories\Factory; 8 9 use Illuminate\Support\Facades\Storage; 10 use function Sodium\increment; 9 11 10 12 class DepartmentFactory extends Factory … … 24 26 public function definition() 25 27 { 26 $location = $this->faker->unique()->numberBetween(1 , 15);28 $location = $this->faker->unique()->numberBetween(10, 25); 27 29 Storage::disk('uploads')->makeDirectory('Departments/' . $location); 28 30 return [ 29 'name' => "Department" . $this->faker->unique()->firstName(),31 'name' => "Department" . ' ' . $this->faker->unique()->firstName(), 30 32 'code' => $location, 31 33 '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() 34 37 ]; 35 38 } -
database/factories/FolderFactory.php
rc6b84df r4b7e2d3 6 6 use App\Models\Folder; 7 7 use Carbon\Carbon; 8 use Faker\Provider\DateTime; 8 9 use Illuminate\Database\Eloquent\Factories\Factory; 9 10 use Illuminate\Support\Facades\Storage; … … 27 28 28 29 $deptId = $this->faker->numberBetween('1', '15'); 30 29 31 $deptCode = Department::find($deptId)->code; 30 32 $name = $this->faker->unique()->firstName(); … … 33 35 Storage::disk('uploads')->makeDirectory($location); 34 36 35 36 37 return [ 37 38 'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(), 38 39 'name' => $name, 39 'note' => $this->faker->realText(),40 'note' => "This a note field", 40 41 'location' => $location, 41 42 'user_id' => $this->faker->numberBetween('1', '2'), -
database/factories/UserFactory.php
rc6b84df r4b7e2d3 26 26 'name' => $this->faker->firstName(), 27 27 'surname' => $this->faker->lastName(), 28 'username' => $this->faker->u serName(),28 'username' => $this->faker->unique()->userName(), 29 29 'password' => $this->faker->password(), 30 'email' => $this->faker-> email(),30 'email' => $this->faker->unique()->email(), 31 31 'phone_number' => $this->faker->phoneNumber(), 32 32 'role_id' => $this->faker->numberBetween(1, 2), … … 35 35 'is_forgot_password' => $this->faker->boolean, 36 36 'created_by' => "1", 37 'created_at' => Carbon::now()37 'created_at' => now() 38 38 ]; 39 39 } -
database/migrations/2021_09_29_121244_create_departments_table.php
rc6b84df r4b7e2d3 16 16 Schema::create('departments', function (Blueprint $table) { 17 17 $table->increments('id'); 18 $table->integer("user_id")->unsigned();19 18 $table->string("name"); 20 19 $table->string("code"); 20 $table->integer("user_id")->unsigned(); 21 21 $table->string("location"); 22 $table->integer("no_of_folders")->default(0); 22 23 $table->timestamps(); 23 24 -
database/migrations/2021_10_06_103305_create_folders_table.php
rc6b84df r4b7e2d3 20 20 $table->text("note")->nullable(); 21 21 $table->string("location"); 22 $table->integer("no_of_files")->default(0); 22 23 $table->integer("user_id")->unsigned(); 23 24 $table->integer("department_id")->unsigned(); -
database/migrations/2021_10_21_144552_create_file_types_table.php
rc6b84df r4b7e2d3 16 16 Schema::create('file_types', function (Blueprint $table) { 17 17 $table->increments('id'); 18 $table->string("mimes")->default(' mimes:');18 $table->string("mimes")->default('jpg,jpeg,png,pdf,docx,xls,xlsx,txt,ppt,pptx'); 19 19 $table->integer("max_size"); 20 20 $table->integer("user_id")->unsigned(); -
database/seeders/DatabaseSeeder.php
rc6b84df r4b7e2d3 19 19 $this->call(UsersTableSeeder::class); 20 20 $this->call(DepartmentsTableSeeder::class); 21 $this->call(FileType Seeder::class);21 $this->call(FileTypesTableSeeder::class); 22 22 $this->call(FoldersTableSeeder::class); 23 $this->call(FilesTableSeeder::class); 23 24 } 24 25 } -
database/seeders/DepartmentsTableSeeder.php
rc6b84df r4b7e2d3 4 4 5 5 use App\Models\Department; 6 use App\Models\Folder; 7 use App\Models\User; 6 8 use Carbon\Carbon; 7 9 use Illuminate\Database\Seeder; -
database/seeders/FileTypesTableSeeder.php
rc6b84df r4b7e2d3 6 6 use Illuminate\Database\Seeder; 7 7 8 class FileType Seeder extends Seeder8 class FileTypesTableSeeder extends Seeder 9 9 { 10 10 /** … … 16 16 { 17 17 \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", 19 19 "max_size" => "5000", 20 20 "user_id" => "1", -
database/seeders/FoldersTableSeeder.php
rc6b84df r4b7e2d3 3 3 namespace Database\Seeders; 4 4 5 use App\Models\Department; 5 6 use App\Models\Folder; 6 7 use Carbon\Carbon; … … 16 17 public function run() 17 18 { 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 } 19 25 } 20 26 } -
database/seeders/UsersTableSeeder.php
rc6b84df r4b7e2d3 27 27 "is_confirmed" => true, 28 28 "created_by" => "1", 29 "created_at" => Carbon::now()29 "created_at" => now() 30 30 ]); 31 31 32 User::factory()->count( 20)->create();32 User::factory()->count(50)->create(); 33 33 34 34 }
Note:
See TracChangeset
for help on using the changeset viewer.