completely brought over database files
This commit is contained in:
parent
ef5656cf04
commit
dbd6bdce51
8 changed files with 322 additions and 4 deletions
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('job_listings', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('employers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('employers');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('ratings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->integer('score');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ratings');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('job_rating', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Job;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
@ -13,12 +15,17 @@ class DatabaseSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// User::factory(10)->create();
|
|
||||||
|
|
||||||
User::factory()->create([
|
User::factory()->create([
|
||||||
'first_name' => 'Test',
|
'first_name' => 'John',
|
||||||
'last_name' => 'Test',
|
'last_name' => 'Doe',
|
||||||
'email' => 'test@example.com',
|
'email' => 'test@example.com',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->call([
|
||||||
|
JobSeeder::class,
|
||||||
|
EmployerJobSeeder::class,
|
||||||
|
JobRatingSeeder::class,
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
86
database/seeders/EmployerJobSeeder.php
Normal file
86
database/seeders/EmployerJobSeeder.php
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
|
||||||
|
class EmployerJobSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('employer_job')->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!');
|
||||||
|
}
|
||||||
|
}
|
86
database/seeders/JobRatingSeeder.php
Normal file
86
database/seeders/JobRatingSeeder.php
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
|
||||||
|
class JobRatingSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('job_rating')->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!');
|
||||||
|
}
|
||||||
|
}
|
17
database/seeders/JobSeeder.php
Normal file
17
database/seeders/JobSeeder.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Job;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class JobSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
Job::factory(33)->create();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue