From dbd6bdce511421bf9af78813fe4b04a673aab057 Mon Sep 17 00:00:00 2001 From: xander Date: Wed, 26 Mar 2025 17:39:51 +0000 Subject: [PATCH] completely brought over database files --- ...03_21_151800_create_job_listings_table.php | 31 +++++++ ...24_03_25_144504_create_employers_table.php | 28 ++++++ ...2024_03_27_141937_create_ratings_table.php | 28 ++++++ .../2024_03_27_151937_create_pivots_table.php | 35 ++++++++ database/seeders/DatabaseSeeder.php | 15 +++- database/seeders/EmployerJobSeeder.php | 86 +++++++++++++++++++ database/seeders/JobRatingSeeder.php | 86 +++++++++++++++++++ database/seeders/JobSeeder.php | 17 ++++ 8 files changed, 322 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2024_03_21_151800_create_job_listings_table.php create mode 100644 database/migrations/2024_03_25_144504_create_employers_table.php create mode 100644 database/migrations/2024_03_27_141937_create_ratings_table.php create mode 100644 database/migrations/2024_03_27_151937_create_pivots_table.php create mode 100644 database/seeders/EmployerJobSeeder.php create mode 100644 database/seeders/JobRatingSeeder.php create mode 100644 database/seeders/JobSeeder.php diff --git a/database/migrations/2024_03_21_151800_create_job_listings_table.php b/database/migrations/2024_03_21_151800_create_job_listings_table.php new file mode 100644 index 0000000..38ae048 --- /dev/null +++ b/database/migrations/2024_03_21_151800_create_job_listings_table.php @@ -0,0 +1,31 @@ +id(); +// $table->unsignedBigInteger('employer_id'); + $table->foreignIdFor(\App\Models\Employer::class); + $table->string('title'); + $table->string('salary'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('job_listings'); + } +}; diff --git a/database/migrations/2024_03_25_144504_create_employers_table.php b/database/migrations/2024_03_25_144504_create_employers_table.php new file mode 100644 index 0000000..440e6d4 --- /dev/null +++ b/database/migrations/2024_03_25_144504_create_employers_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('employers'); + } +}; diff --git a/database/migrations/2024_03_27_141937_create_ratings_table.php b/database/migrations/2024_03_27_141937_create_ratings_table.php new file mode 100644 index 0000000..0d6c6eb --- /dev/null +++ b/database/migrations/2024_03_27_141937_create_ratings_table.php @@ -0,0 +1,28 @@ +id(); + $table->integer('score'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('ratings'); + } +}; diff --git a/database/migrations/2024_03_27_151937_create_pivots_table.php b/database/migrations/2024_03_27_151937_create_pivots_table.php new file mode 100644 index 0000000..0a3a60c --- /dev/null +++ b/database/migrations/2024_03_27_151937_create_pivots_table.php @@ -0,0 +1,35 @@ +id(); + $table->foreignIdFor(\App\Models\Job::class, 'job_listing_id')->constrained()->cascadeOnDelete(); + $table->foreignIdFor(\App\Models\Rating::class)->constrained()->cascadeOnDelete(); + }); + + Schema::create('employer_job', function (Blueprint $table) { + $table->id(); + $table->foreignIdFor(\App\Models\Job::class, 'job_listing_id')->constrained()->cascadeOnDelete(); + $table->foreignIdFor(\App\Models\Employer::class)->constrained()->cascadeOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('job_rating'); + Schema::dropIfExists('employer_job'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index fba1c2d..a496718 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,7 +2,9 @@ namespace Database\Seeders; +use App\Models\Job; use App\Models\User; +use Illuminate\Support\Facades\DB; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; @@ -13,12 +15,17 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // User::factory(10)->create(); - User::factory()->create([ - 'first_name' => 'Test', - 'last_name' => 'Test', + 'first_name' => 'John', + 'last_name' => 'Doe', 'email' => 'test@example.com', ]); + + $this->call([ + JobSeeder::class, + EmployerJobSeeder::class, + JobRatingSeeder::class, + ]); + } } diff --git a/database/seeders/EmployerJobSeeder.php b/database/seeders/EmployerJobSeeder.php new file mode 100644 index 0000000..b7f078e --- /dev/null +++ b/database/seeders/EmployerJobSeeder.php @@ -0,0 +1,86 @@ +insert( [ + [ "employer_id" => 1, "job_listing_id" => 1], + [ "employer_id" => 10, "job_listing_id" => 2], + [ "employer_id" => 1, "job_listing_id" => 3], + [ "employer_id" => 1, "job_listing_id" => 4], + [ "employer_id" => 6, "job_listing_id" => 4], + [ "employer_id" => 7, "job_listing_id" => 4], + [ "employer_id" => 1, "job_listing_id" => 5], + [ "employer_id" => 1, "job_listing_id" => 6], + [ "employer_id" => 2, "job_listing_id" => 6], + [ "employer_id" => 7, "job_listing_id" => 7], + [ "employer_id" => 9, "job_listing_id" => 7], + [ "employer_id" => 1, "job_listing_id" => 8], + [ "employer_id" => 2, "job_listing_id" => 8], + [ "employer_id" => 1, "job_listing_id" => 9], + [ "employer_id" => 2, "job_listing_id" => 9], + [ "employer_id" => 1, "job_listing_id" => 10], + [ "employer_id" => 2, "job_listing_id" => 10], + [ "employer_id" => 1, "job_listing_id" => 11], + [ "employer_id" => 2, "job_listing_id" => 11], + [ "employer_id" => 1, "job_listing_id" => 12], + [ "employer_id" => 1, "job_listing_id" => 13], + [ "employer_id" => 2, "job_listing_id" => 13], + [ "employer_id" => 1, "job_listing_id" => 14], + [ "employer_id" => 3, "job_listing_id" => 14], + [ "employer_id" => 1, "job_listing_id" => 15], + [ "employer_id" => 2, "job_listing_id" => 15], + [ "employer_id" => 1, "job_listing_id" => 16], + [ "employer_id" => 2, "job_listing_id" => 16], + [ "employer_id" => 7, "job_listing_id" => 17], + [ "employer_id" => 1, "job_listing_id" => 17], + [ "employer_id" => 1, "job_listing_id" => 18], + [ "employer_id" => 2, "job_listing_id" => 18], + [ "employer_id" => 1, "job_listing_id" => 19], + [ "employer_id" => 2, "job_listing_id" => 19], + [ "employer_id" => 1, "job_listing_id" => 20], + [ "employer_id" => 2, "job_listing_id" => 20], + [ "employer_id" => 1, "job_listing_id" => 21], + [ "employer_id" => 3, "job_listing_id" => 21], + [ "employer_id" => 1, "job_listing_id" => 22], + [ "employer_id" => 10, "job_listing_id" => 22], + [ "employer_id" => 1, "job_listing_id" => 23], + [ "employer_id" => 11, "job_listing_id" => 23], + [ "employer_id" => 12, "job_listing_id" => 23], + [ "employer_id" => 1, "job_listing_id" => 24], + [ "employer_id" => 11, "job_listing_id" => 24], + [ "employer_id" => 12, "job_listing_id" => 24], + [ "employer_id" => 1, "job_listing_id" => 25], + [ "employer_id" => 11, "job_listing_id" => 25], + [ "employer_id" => 12, "job_listing_id" => 25], + [ "employer_id" => 1, "job_listing_id" => 26], + [ "employer_id" => 11, "job_listing_id" => 26], + [ "employer_id" => 12, "job_listing_id" => 26], + [ "employer_id" => 5, "job_listing_id" => 27], + [ "employer_id" => 10, "job_listing_id" => 27], + [ "employer_id" => 13, "job_listing_id" => 27], + [ "employer_id" => 5, "job_listing_id" => 28], + [ "employer_id" => 10, "job_listing_id" => 28], + [ "employer_id" => 13, "job_listing_id" => 28], + [ "employer_id" => 8, "job_listing_id" => 29], + [ "employer_id" => 9, "job_listing_id" => 29], + [ "employer_id" => 5, "job_listing_id" => 30], + [ "employer_id" => 10, "job_listing_id" => 30], + [ "employer_id" => 13, "job_listing_id" => 30], + [ "employer_id" => 1, "job_listing_id" => 31], + [ "employer_id" => 1, "job_listing_id" => 32], + [ "employer_id" => 4, "job_listing_id" => 32] + ]); + $this->command->info('Seeded the Relationships of Jobs to Employers!'); + } +} diff --git a/database/seeders/JobRatingSeeder.php b/database/seeders/JobRatingSeeder.php new file mode 100644 index 0000000..62752e9 --- /dev/null +++ b/database/seeders/JobRatingSeeder.php @@ -0,0 +1,86 @@ +insert( [ + [ "rating_id" => 1, "job_listing_id" => 1], + [ "rating_id" => 10, "job_listing_id" => 2], + [ "rating_id" => 1, "job_listing_id" => 3], + [ "rating_id" => 1, "job_listing_id" => 4], + [ "rating_id" => 6, "job_listing_id" => 4], + [ "rating_id" => 7, "job_listing_id" => 4], + [ "rating_id" => 1, "job_listing_id" => 5], + [ "rating_id" => 1, "job_listing_id" => 6], + [ "rating_id" => 2, "job_listing_id" => 6], + [ "rating_id" => 7, "job_listing_id" => 7], + [ "rating_id" => 9, "job_listing_id" => 7], + [ "rating_id" => 1, "job_listing_id" => 8], + [ "rating_id" => 2, "job_listing_id" => 8], + [ "rating_id" => 1, "job_listing_id" => 9], + [ "rating_id" => 2, "job_listing_id" => 9], + [ "rating_id" => 1, "job_listing_id" => 10], + [ "rating_id" => 2, "job_listing_id" => 10], + [ "rating_id" => 1, "job_listing_id" => 11], + [ "rating_id" => 2, "job_listing_id" => 11], + [ "rating_id" => 1, "job_listing_id" => 12], + [ "rating_id" => 1, "job_listing_id" => 13], + [ "rating_id" => 2, "job_listing_id" => 13], + [ "rating_id" => 1, "job_listing_id" => 14], + [ "rating_id" => 3, "job_listing_id" => 14], + [ "rating_id" => 1, "job_listing_id" => 15], + [ "rating_id" => 2, "job_listing_id" => 15], + [ "rating_id" => 1, "job_listing_id" => 16], + [ "rating_id" => 2, "job_listing_id" => 16], + [ "rating_id" => 7, "job_listing_id" => 17], + [ "rating_id" => 1, "job_listing_id" => 17], + [ "rating_id" => 1, "job_listing_id" => 18], + [ "rating_id" => 2, "job_listing_id" => 18], + [ "rating_id" => 1, "job_listing_id" => 19], + [ "rating_id" => 2, "job_listing_id" => 19], + [ "rating_id" => 1, "job_listing_id" => 20], + [ "rating_id" => 2, "job_listing_id" => 20], + [ "rating_id" => 1, "job_listing_id" => 21], + [ "rating_id" => 3, "job_listing_id" => 21], + [ "rating_id" => 1, "job_listing_id" => 22], + [ "rating_id" => 10, "job_listing_id" => 22], + [ "rating_id" => 1, "job_listing_id" => 23], + [ "rating_id" => 11, "job_listing_id" => 23], + [ "rating_id" => 12, "job_listing_id" => 23], + [ "rating_id" => 1, "job_listing_id" => 24], + [ "rating_id" => 11, "job_listing_id" => 24], + [ "rating_id" => 12, "job_listing_id" => 24], + [ "rating_id" => 1, "job_listing_id" => 25], + [ "rating_id" => 11, "job_listing_id" => 25], + [ "rating_id" => 12, "job_listing_id" => 25], + [ "rating_id" => 1, "job_listing_id" => 26], + [ "rating_id" => 11, "job_listing_id" => 26], + [ "rating_id" => 12, "job_listing_id" => 26], + [ "rating_id" => 5, "job_listing_id" => 27], + [ "rating_id" => 10, "job_listing_id" => 27], + [ "rating_id" => 13, "job_listing_id" => 27], + [ "rating_id" => 5, "job_listing_id" => 28], + [ "rating_id" => 10, "job_listing_id" => 28], + [ "rating_id" => 13, "job_listing_id" => 28], + [ "rating_id" => 8, "job_listing_id" => 29], + [ "rating_id" => 9, "job_listing_id" => 29], + [ "rating_id" => 5, "job_listing_id" => 30], + [ "rating_id" => 10, "job_listing_id" => 30], + [ "rating_id" => 13, "job_listing_id" => 30], + [ "rating_id" => 1, "job_listing_id" => 31], + [ "rating_id" => 1, "job_listing_id" => 32], + [ "rating_id" => 4, "job_listing_id" => 32] + ]); + $this->command->info('Seeded the Relationships of Ratings to Jobs!'); + } +} diff --git a/database/seeders/JobSeeder.php b/database/seeders/JobSeeder.php new file mode 100644 index 0000000..9861de8 --- /dev/null +++ b/database/seeders/JobSeeder.php @@ -0,0 +1,17 @@ +create(); + } +}