From cd3c2040ee46dd086a674add8c8b83f8bb49703f Mon Sep 17 00:00:00 2001 From: DavidK031 Date: Mon, 20 Oct 2025 20:28:05 +0200 Subject: [PATCH 1/9] =?UTF-8?q?Migr=C3=A1cia=20datab=C3=A1zy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0_add_role_phone_active_to_users_table.php | 0 ...10_20_120100_create_student_data_table.php | 0 ...25_10_20_120200_create_companies_table.php | 0 ...25_10_20_120300_create_employers_table.php | 0 ..._10_20_120400_create_internships_table.php | 0 ...20500_create_internship_statuses_table.php | 0 ...20_120600_add_status_fk_to_internships.php | 20 +++++++++++++++++++ 7 files changed, 20 insertions(+) create mode 100644 backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php create mode 100644 backend/database/migrations/2025_10_20_120100_create_student_data_table.php create mode 100644 backend/database/migrations/2025_10_20_120200_create_companies_table.php create mode 100644 backend/database/migrations/2025_10_20_120300_create_employers_table.php create mode 100644 backend/database/migrations/2025_10_20_120400_create_internships_table.php create mode 100644 backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php create mode 100644 backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php diff --git a/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php b/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/migrations/2025_10_20_120100_create_student_data_table.php b/backend/database/migrations/2025_10_20_120100_create_student_data_table.php new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/migrations/2025_10_20_120200_create_companies_table.php b/backend/database/migrations/2025_10_20_120200_create_companies_table.php new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/migrations/2025_10_20_120300_create_employers_table.php b/backend/database/migrations/2025_10_20_120300_create_employers_table.php new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/migrations/2025_10_20_120400_create_internships_table.php b/backend/database/migrations/2025_10_20_120400_create_internships_table.php new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php b/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php b/backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php new file mode 100644 index 0000000..fbf5e7c --- /dev/null +++ b/backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php @@ -0,0 +1,20 @@ +foreign('status_id') + ->references('id')->on('internship_statuses') + ->nullOnDelete(); + }); + } + public function down(): void { + Schema::table('internships', function (Blueprint $table) { + $table->dropForeign(['status_id']); + }); + } +}; From 91c2c302ee463a0c1d4dba2ecd7bc860b00da7fc Mon Sep 17 00:00:00 2001 From: DavidK031 Date: Mon, 20 Oct 2025 20:47:11 +0200 Subject: [PATCH 2/9] Uprava --- ...10_20_120100_create_student_data_table.php | 21 ++++++++++ ...25_10_20_120300_create_employers_table.php | 20 ++++++++++ ..._10_20_120400_create_internships_table.php | 38 +++++++++++++++++++ ...20500_create_internship_statuses_table.php | 25 ++++++++++++ 4 files changed, 104 insertions(+) diff --git a/backend/database/migrations/2025_10_20_120100_create_student_data_table.php b/backend/database/migrations/2025_10_20_120100_create_student_data_table.php index e69de29..b46d14e 100644 --- a/backend/database/migrations/2025_10_20_120100_create_student_data_table.php +++ b/backend/database/migrations/2025_10_20_120100_create_student_data_table.php @@ -0,0 +1,21 @@ +id(); + $table->foreignId('user_id')->unique()->constrained('users')->cascadeOnDelete(); + $table->string('address')->nullable(); + $table->string('personal_email')->nullable(); + $table->string('study_field')->nullable(); + $table->timestamps(); + }); + } + public function down(): void { + Schema::dropIfExists('student_data'); + } +}; diff --git a/backend/database/migrations/2025_10_20_120300_create_employers_table.php b/backend/database/migrations/2025_10_20_120300_create_employers_table.php index e69de29..96c9e89 100644 --- a/backend/database/migrations/2025_10_20_120300_create_employers_table.php +++ b/backend/database/migrations/2025_10_20_120300_create_employers_table.php @@ -0,0 +1,20 @@ +id(); + $table->foreignId('company_id')->constrained('companies')->cascadeOnDelete(); + $table->foreignId('user_id')->unique()->constrained('users')->cascadeOnDelete(); + $table->string('position')->nullable(); + $table->timestamps(); + }); + } + public function down(): void { + Schema::dropIfExists('employers'); + } +}; diff --git a/backend/database/migrations/2025_10_20_120400_create_internships_table.php b/backend/database/migrations/2025_10_20_120400_create_internships_table.php index e69de29..7abbfd4 100644 --- a/backend/database/migrations/2025_10_20_120400_create_internships_table.php +++ b/backend/database/migrations/2025_10_20_120400_create_internships_table.php @@ -0,0 +1,38 @@ +id(); + + + $table->foreignId('user_id')->constrained('users'); + $table->foreignId('company_id')->constrained('companies'); + $table->foreignId('employer_id')->nullable()->constrained('employers')->nullOnDelete(); + + + $table->string('agreement')->nullable(); + $table->date('start_date'); + $table->date('end_date'); + $table->enum('semester', ['ZS','LS']); + $table->smallInteger('year_of_study'); + $table->text('position_description')->nullable(); + $table->boolean('is_paid')->default(false); + + + $table->unsignedBigInteger('status_id')->nullable(); + + $table->timestamps(); + + $table->index(['semester','company_id','user_id','status_id']); + + }); + } + public function down(): void { + Schema::dropIfExists('internships'); + } +}; diff --git a/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php b/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php index e69de29..53d4e3c 100644 --- a/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php +++ b/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php @@ -0,0 +1,25 @@ +id(); + $table->foreignId('internship_id')->constrained('internships')->cascadeOnDelete(); + $table->enum('status', ['SUBMITTED','CONFIRMED','DENIED','DEFENDED','NOT_DEFENDED']); + $table->timestamp('changed')->useCurrent(); + $table->foreignId('modified_by')->nullable()->constrained('users')->nullOnDelete(); + $table->text('note')->nullable(); + $table->string('source', 30)->default('UI'); + $table->timestamps(); + + $table->index(['internship_id','status']); + }); + } + public function down(): void { + Schema::dropIfExists('internship_statuses'); + } +}; From 6811fb43e548a9b550fcb77ba3ae1e6d443e52a4 Mon Sep 17 00:00:00 2001 From: dkecskes Date: Mon, 20 Oct 2025 21:01:09 +0200 Subject: [PATCH 3/9] doplnenie migracii --- ...0_add_role_phone_active_to_users_table.php | 20 ++++++++++++++++++ ...25_10_20_120200_create_companies_table.php | 21 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php b/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php index e69de29..6fc7f46 100644 --- a/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php +++ b/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php @@ -0,0 +1,20 @@ +string('phone')->nullable()->after('email'); + $table->enum('role', ['STUDENT','EMPLOYER','ADMIN'])->default('STUDENT')->after('phone'); + $table->boolean('is_active')->default(true)->after('role'); + }); + } + public function down(): void { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['phone','role','is_active']); + }); + } +}; diff --git a/backend/database/migrations/2025_10_20_120200_create_companies_table.php b/backend/database/migrations/2025_10_20_120200_create_companies_table.php index e69de29..09c83d9 100644 --- a/backend/database/migrations/2025_10_20_120200_create_companies_table.php +++ b/backend/database/migrations/2025_10_20_120200_create_companies_table.php @@ -0,0 +1,21 @@ +id(); + $table->string('name'); + $table->string('ICO', 20)->nullable()->unique(); + $table->string('address'); + $table->boolean('hiring')->default(false); + $table->timestamps(); + }); + } + public function down(): void { + Schema::dropIfExists('companies'); + } +}; From f9902c2ed1c137614aa5a995510373f9b81ddf68 Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:38:31 +0200 Subject: [PATCH 4/9] refactor: improve migrations and update `User` fields --- backend/app/Models/User.php | 4 ++ ...0_add_role_phone_active_to_users_table.php | 20 ---------- ...10_20_120100_create_student_data_table.php | 21 ---------- ...25_10_20_120200_create_companies_table.php | 21 ---------- ...25_10_20_120300_create_employers_table.php | 20 ---------- ..._10_20_120400_create_internships_table.php | 38 ------------------- ...20500_create_internship_statuses_table.php | 25 ------------ ...20_120600_add_status_fk_to_internships.php | 20 ---------- .../2025_10_20_191423_alter_users_table.php | 38 +++++++++++++++++++ ...10_20_192305_create_student_data_table.php | 31 +++++++++++++++ ...25_10_20_192651_create_companies_table.php | 31 +++++++++++++++ ...25_10_20_192915_create_employers_table.php | 29 ++++++++++++++ ..._10_20_193012_create_internships_table.php | 37 ++++++++++++++++++ ...93408_create_internship_statuses_table.php | 32 ++++++++++++++++ 14 files changed, 202 insertions(+), 165 deletions(-) delete mode 100644 backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php delete mode 100644 backend/database/migrations/2025_10_20_120100_create_student_data_table.php delete mode 100644 backend/database/migrations/2025_10_20_120200_create_companies_table.php delete mode 100644 backend/database/migrations/2025_10_20_120300_create_employers_table.php delete mode 100644 backend/database/migrations/2025_10_20_120400_create_internships_table.php delete mode 100644 backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php delete mode 100644 backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php create mode 100644 backend/database/migrations/2025_10_20_191423_alter_users_table.php create mode 100644 backend/database/migrations/2025_10_20_192305_create_student_data_table.php create mode 100644 backend/database/migrations/2025_10_20_192651_create_companies_table.php create mode 100644 backend/database/migrations/2025_10_20_192915_create_employers_table.php create mode 100644 backend/database/migrations/2025_10_20_193012_create_internships_table.php create mode 100644 backend/database/migrations/2025_10_20_193408_create_internship_statuses_table.php diff --git a/backend/app/Models/User.php b/backend/app/Models/User.php index 749c7b7..97edce1 100644 --- a/backend/app/Models/User.php +++ b/backend/app/Models/User.php @@ -19,7 +19,11 @@ class User extends Authenticatable */ protected $fillable = [ 'name', + 'first_name', + 'last_name', + 'phone', 'email', + 'role', 'password', ]; diff --git a/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php b/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php deleted file mode 100644 index 6fc7f46..0000000 --- a/backend/database/migrations/2025_10_20_120000_add_role_phone_active_to_users_table.php +++ /dev/null @@ -1,20 +0,0 @@ -string('phone')->nullable()->after('email'); - $table->enum('role', ['STUDENT','EMPLOYER','ADMIN'])->default('STUDENT')->after('phone'); - $table->boolean('is_active')->default(true)->after('role'); - }); - } - public function down(): void { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn(['phone','role','is_active']); - }); - } -}; diff --git a/backend/database/migrations/2025_10_20_120100_create_student_data_table.php b/backend/database/migrations/2025_10_20_120100_create_student_data_table.php deleted file mode 100644 index b46d14e..0000000 --- a/backend/database/migrations/2025_10_20_120100_create_student_data_table.php +++ /dev/null @@ -1,21 +0,0 @@ -id(); - $table->foreignId('user_id')->unique()->constrained('users')->cascadeOnDelete(); - $table->string('address')->nullable(); - $table->string('personal_email')->nullable(); - $table->string('study_field')->nullable(); - $table->timestamps(); - }); - } - public function down(): void { - Schema::dropIfExists('student_data'); - } -}; diff --git a/backend/database/migrations/2025_10_20_120200_create_companies_table.php b/backend/database/migrations/2025_10_20_120200_create_companies_table.php deleted file mode 100644 index 09c83d9..0000000 --- a/backend/database/migrations/2025_10_20_120200_create_companies_table.php +++ /dev/null @@ -1,21 +0,0 @@ -id(); - $table->string('name'); - $table->string('ICO', 20)->nullable()->unique(); - $table->string('address'); - $table->boolean('hiring')->default(false); - $table->timestamps(); - }); - } - public function down(): void { - Schema::dropIfExists('companies'); - } -}; diff --git a/backend/database/migrations/2025_10_20_120300_create_employers_table.php b/backend/database/migrations/2025_10_20_120300_create_employers_table.php deleted file mode 100644 index 96c9e89..0000000 --- a/backend/database/migrations/2025_10_20_120300_create_employers_table.php +++ /dev/null @@ -1,20 +0,0 @@ -id(); - $table->foreignId('company_id')->constrained('companies')->cascadeOnDelete(); - $table->foreignId('user_id')->unique()->constrained('users')->cascadeOnDelete(); - $table->string('position')->nullable(); - $table->timestamps(); - }); - } - public function down(): void { - Schema::dropIfExists('employers'); - } -}; diff --git a/backend/database/migrations/2025_10_20_120400_create_internships_table.php b/backend/database/migrations/2025_10_20_120400_create_internships_table.php deleted file mode 100644 index 7abbfd4..0000000 --- a/backend/database/migrations/2025_10_20_120400_create_internships_table.php +++ /dev/null @@ -1,38 +0,0 @@ -id(); - - - $table->foreignId('user_id')->constrained('users'); - $table->foreignId('company_id')->constrained('companies'); - $table->foreignId('employer_id')->nullable()->constrained('employers')->nullOnDelete(); - - - $table->string('agreement')->nullable(); - $table->date('start_date'); - $table->date('end_date'); - $table->enum('semester', ['ZS','LS']); - $table->smallInteger('year_of_study'); - $table->text('position_description')->nullable(); - $table->boolean('is_paid')->default(false); - - - $table->unsignedBigInteger('status_id')->nullable(); - - $table->timestamps(); - - $table->index(['semester','company_id','user_id','status_id']); - - }); - } - public function down(): void { - Schema::dropIfExists('internships'); - } -}; diff --git a/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php b/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php deleted file mode 100644 index 53d4e3c..0000000 --- a/backend/database/migrations/2025_10_20_120500_create_internship_statuses_table.php +++ /dev/null @@ -1,25 +0,0 @@ -id(); - $table->foreignId('internship_id')->constrained('internships')->cascadeOnDelete(); - $table->enum('status', ['SUBMITTED','CONFIRMED','DENIED','DEFENDED','NOT_DEFENDED']); - $table->timestamp('changed')->useCurrent(); - $table->foreignId('modified_by')->nullable()->constrained('users')->nullOnDelete(); - $table->text('note')->nullable(); - $table->string('source', 30)->default('UI'); - $table->timestamps(); - - $table->index(['internship_id','status']); - }); - } - public function down(): void { - Schema::dropIfExists('internship_statuses'); - } -}; diff --git a/backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php b/backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php deleted file mode 100644 index fbf5e7c..0000000 --- a/backend/database/migrations/2025_10_20_120600_add_status_fk_to_internships.php +++ /dev/null @@ -1,20 +0,0 @@ -foreign('status_id') - ->references('id')->on('internship_statuses') - ->nullOnDelete(); - }); - } - public function down(): void { - Schema::table('internships', function (Blueprint $table) { - $table->dropForeign(['status_id']); - }); - } -}; diff --git a/backend/database/migrations/2025_10_20_191423_alter_users_table.php b/backend/database/migrations/2025_10_20_191423_alter_users_table.php new file mode 100644 index 0000000..9041dde --- /dev/null +++ b/backend/database/migrations/2025_10_20_191423_alter_users_table.php @@ -0,0 +1,38 @@ +string('first_name')->nullable(false)->after('name'); + $table->string('last_name')->nullable(false)->after('first_name'); + $table->string('phone')->nullable(false)->unique()->after('email'); + $table->enum("role", ["STUDENT", "EMPLOYER", "ADMIN"])->nullable(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropUnique(['phone']); + + $table->dropColumn([ + 'first_name', + 'last_name', + 'phone', + 'role', + ]); + }); + } +}; diff --git a/backend/database/migrations/2025_10_20_192305_create_student_data_table.php b/backend/database/migrations/2025_10_20_192305_create_student_data_table.php new file mode 100644 index 0000000..af27da8 --- /dev/null +++ b/backend/database/migrations/2025_10_20_192305_create_student_data_table.php @@ -0,0 +1,31 @@ +id(); + $table->foreignId("user_id")->nullable(false)->constrained("users")->onDelete("cascade"); + $table->string("address")->nullable(false); + $table->string("personal_email")->nullable(false); + $table->string("study_field")->nullable(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('student_data'); + } +}; diff --git a/backend/database/migrations/2025_10_20_192651_create_companies_table.php b/backend/database/migrations/2025_10_20_192651_create_companies_table.php new file mode 100644 index 0000000..ae58858 --- /dev/null +++ b/backend/database/migrations/2025_10_20_192651_create_companies_table.php @@ -0,0 +1,31 @@ +id(); + $table->string("name")->nullable(false)->unique(); + $table->string("address")->nullable(false); + $table->unsignedInteger("ico")->nullable(false)->unique(); + $table->boolean("hiring")->nullable(false)->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('companies'); + } +}; diff --git a/backend/database/migrations/2025_10_20_192915_create_employers_table.php b/backend/database/migrations/2025_10_20_192915_create_employers_table.php new file mode 100644 index 0000000..a1fd10c --- /dev/null +++ b/backend/database/migrations/2025_10_20_192915_create_employers_table.php @@ -0,0 +1,29 @@ +id(); + $table->foreignId("user_id")->nullable(false)->constrained("users")->onDelete("cascade"); + $table->foreignId("company_id")->nullable(false)->constrained("companies")->onDelete("cascade"); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('employers'); + } +}; diff --git a/backend/database/migrations/2025_10_20_193012_create_internships_table.php b/backend/database/migrations/2025_10_20_193012_create_internships_table.php new file mode 100644 index 0000000..35295a1 --- /dev/null +++ b/backend/database/migrations/2025_10_20_193012_create_internships_table.php @@ -0,0 +1,37 @@ +id(); + $table->foreignId("user_id")->nullable(false)->constrained("users")->onDelete("cascade"); + $table->foreignId("company_id")->nullable(false)->constrained("companies")->onDelete("cascade"); + $table->dateTimeTz("start")->nullable(false); + $table->dateTimeTz("end")->nullable(false); + $table->unsignedSmallInteger("year_of_study")->nullable(false); + $table->enum("semester", ["WINTER", "SUMMER"])->nullable(false); + $table->string("position_description")->nullable(false); + $table->binary("agreement")->nullable(true); + $table->foreignId("personel_id")->nullable(false)->constrained("users")->onDelete("cascade"); + $table->foreignId("status_id")->nullable(false)->constrained("internship_statuses")->onDelete("cascade"); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('internships'); + } +}; diff --git a/backend/database/migrations/2025_10_20_193408_create_internship_statuses_table.php b/backend/database/migrations/2025_10_20_193408_create_internship_statuses_table.php new file mode 100644 index 0000000..a54ffa7 --- /dev/null +++ b/backend/database/migrations/2025_10_20_193408_create_internship_statuses_table.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId("internship_id")->nullable(false)->constrained("internships")->onDelete("cascade"); + $table->enum("status", ["SUBMITTED", "CONFIRMED", "DENIED", "DEFENDED", "NOT_DEFENDED"])->nullable(false)->default("SUBMITTED"); + $table->dateTimeTz("changed")->nullable(false); + $table->string("note")->nullable(true)->default(null); + $table->foreignId("modified_by")->nullable(false)->constrained("users")->onDelete("cascade"); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('internship_statuses'); + } +}; From ea2f1c537d72093a21b8546348d829975800a254 Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:46:54 +0200 Subject: [PATCH 5/9] refactor: enhance user factory --- backend/database/factories/UserFactory.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/database/factories/UserFactory.php b/backend/database/factories/UserFactory.php index 584104c..39a6cef 100644 --- a/backend/database/factories/UserFactory.php +++ b/backend/database/factories/UserFactory.php @@ -23,8 +23,15 @@ class UserFactory extends Factory */ public function definition(): array { + $first_name = fake()->firstName(); + $last_name = fake()->lastName(); + return [ - 'name' => fake()->name(), + 'name' => "$first_name $last_name", + 'first_name' => $first_name, + 'last_name' => $last_name, + 'phone' => fake()->phoneNumber(), + 'role' => fake()->randomElement(['STUDENT', 'EMPLOYER', 'ADMIN']), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), From 3c45c3f9c95ce539e20e9eb0df18e90ee687f749 Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:50:34 +0200 Subject: [PATCH 6/9] refactor: update `DatabaseSeeder` to create a default admin user with complete details --- backend/database/seeders/DatabaseSeeder.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/database/seeders/DatabaseSeeder.php b/backend/database/seeders/DatabaseSeeder.php index d01a0ef..32db727 100644 --- a/backend/database/seeders/DatabaseSeeder.php +++ b/backend/database/seeders/DatabaseSeeder.php @@ -13,11 +13,14 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // User::factory(10)->create(); - + // create a default admin user User::factory()->create([ 'name' => 'Test User', + 'first_name' => 'Test', + 'last_name' => 'User', 'email' => 'test@example.com', + 'phone' => '+421907444555', + 'role' => 'ADMIN', ]); } } From b4f98718e6d270d4c91719475946cdf672856ee0 Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:02:13 +0200 Subject: [PATCH 7/9] refactor: restrict companies to only one contact --- ...25_10_20_192651_create_companies_table.php | 1 + ...25_10_20_192915_create_employers_table.php | 29 ------------------- 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 backend/database/migrations/2025_10_20_192915_create_employers_table.php diff --git a/backend/database/migrations/2025_10_20_192651_create_companies_table.php b/backend/database/migrations/2025_10_20_192651_create_companies_table.php index ae58858..194936a 100644 --- a/backend/database/migrations/2025_10_20_192651_create_companies_table.php +++ b/backend/database/migrations/2025_10_20_192651_create_companies_table.php @@ -16,6 +16,7 @@ return new class extends Migration $table->string("name")->nullable(false)->unique(); $table->string("address")->nullable(false); $table->unsignedInteger("ico")->nullable(false)->unique(); + $table->foreignId("contact")->nullable(false)->constrained("users")->onDelete("cascade"); $table->boolean("hiring")->nullable(false)->default(false); $table->timestamps(); }); diff --git a/backend/database/migrations/2025_10_20_192915_create_employers_table.php b/backend/database/migrations/2025_10_20_192915_create_employers_table.php deleted file mode 100644 index a1fd10c..0000000 --- a/backend/database/migrations/2025_10_20_192915_create_employers_table.php +++ /dev/null @@ -1,29 +0,0 @@ -id(); - $table->foreignId("user_id")->nullable(false)->constrained("users")->onDelete("cascade"); - $table->foreignId("company_id")->nullable(false)->constrained("companies")->onDelete("cascade"); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('employers'); - } -}; From e3c7bd3a5ac42b1d20b37e4b7d83fd43773476e2 Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:25:54 +0200 Subject: [PATCH 8/9] refactor: create models, factories, and seeders for Company, Internship, InternshipStatus, and StudentData --- .../Http/Controllers/CompanyController.php | 65 +++++++++++++++++++ .../Http/Controllers/InternshipController.php | 65 +++++++++++++++++++ .../InternshipStatusController.php | 65 +++++++++++++++++++ .../Controllers/StudentDataController.php | 65 +++++++++++++++++++ backend/app/Models/Company.php | 25 +++++++ backend/app/Models/Internship.php | 28 ++++++++ backend/app/Models/InternshipStatus.php | 25 +++++++ backend/app/Models/StudentData.php | 24 +++++++ backend/database/factories/CompanyFactory.php | 27 ++++++++ .../database/factories/InternshipFactory.php | 30 +++++++++ .../factories/InternshipStatusFactory.php | 27 ++++++++ .../database/factories/StudentDataFactory.php | 26 ++++++++ ..._10_20_193012_create_internships_table.php | 2 - backend/database/seeders/CompanySeeder.php | 17 +++++ backend/database/seeders/DatabaseSeeder.php | 40 +++++++++++- backend/database/seeders/InternshipSeeder.php | 17 +++++ .../seeders/InternshipStatusSeeder.php | 17 +++++ .../database/seeders/StudentDataSeeder.php | 17 +++++ 18 files changed, 579 insertions(+), 3 deletions(-) create mode 100644 backend/app/Http/Controllers/CompanyController.php create mode 100644 backend/app/Http/Controllers/InternshipController.php create mode 100644 backend/app/Http/Controllers/InternshipStatusController.php create mode 100644 backend/app/Http/Controllers/StudentDataController.php create mode 100644 backend/app/Models/Company.php create mode 100644 backend/app/Models/Internship.php create mode 100644 backend/app/Models/InternshipStatus.php create mode 100644 backend/app/Models/StudentData.php create mode 100644 backend/database/factories/CompanyFactory.php create mode 100644 backend/database/factories/InternshipFactory.php create mode 100644 backend/database/factories/InternshipStatusFactory.php create mode 100644 backend/database/factories/StudentDataFactory.php create mode 100644 backend/database/seeders/CompanySeeder.php create mode 100644 backend/database/seeders/InternshipSeeder.php create mode 100644 backend/database/seeders/InternshipStatusSeeder.php create mode 100644 backend/database/seeders/StudentDataSeeder.php diff --git a/backend/app/Http/Controllers/CompanyController.php b/backend/app/Http/Controllers/CompanyController.php new file mode 100644 index 0000000..171eaad --- /dev/null +++ b/backend/app/Http/Controllers/CompanyController.php @@ -0,0 +1,65 @@ + */ + use HasFactory; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + 'name', + 'address', + 'ico', + 'contact', + 'hiring' + ]; +} diff --git a/backend/app/Models/Internship.php b/backend/app/Models/Internship.php new file mode 100644 index 0000000..a549885 --- /dev/null +++ b/backend/app/Models/Internship.php @@ -0,0 +1,28 @@ + */ + use HasFactory; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + 'user_id', + 'company_id', + 'start', + 'end', + 'year_of_study', + 'semester', + 'position_description', + 'agreement', + ]; +} diff --git a/backend/app/Models/InternshipStatus.php b/backend/app/Models/InternshipStatus.php new file mode 100644 index 0000000..4272c86 --- /dev/null +++ b/backend/app/Models/InternshipStatus.php @@ -0,0 +1,25 @@ + */ + use HasFactory; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + 'internship_id', + 'status', + 'changed', + 'note', + 'modified_by' + ]; +} diff --git a/backend/app/Models/StudentData.php b/backend/app/Models/StudentData.php new file mode 100644 index 0000000..8490416 --- /dev/null +++ b/backend/app/Models/StudentData.php @@ -0,0 +1,24 @@ + */ + use HasFactory; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + 'user_id', + 'address', + 'personal_email', + 'study_field', + ]; +} diff --git a/backend/database/factories/CompanyFactory.php b/backend/database/factories/CompanyFactory.php new file mode 100644 index 0000000..44b328a --- /dev/null +++ b/backend/database/factories/CompanyFactory.php @@ -0,0 +1,27 @@ + + */ +class CompanyFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => fake()->company(), + 'address' => fake()->address(), + 'ico' => fake()->numberBetween(111111, 999999), + 'contact' => 0, + 'hiring' => fake()->boolean(), + ]; + } +} diff --git a/backend/database/factories/InternshipFactory.php b/backend/database/factories/InternshipFactory.php new file mode 100644 index 0000000..d1d9015 --- /dev/null +++ b/backend/database/factories/InternshipFactory.php @@ -0,0 +1,30 @@ + + */ +class InternshipFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'user_id' => 0, + 'company_id' => 0, + 'start' => fake()->dateTime(), + 'end' => fake()->dateTime("+30 days"), + 'year_of_study' => fake()->randomElement([1, 2, 3, 4, 5]), + 'semester' => fake()->randomElement(["WINTER", "SUMMER"]), + 'position_description' => fake()->jobTitle(), + 'agreement' => null, + ]; + } +} diff --git a/backend/database/factories/InternshipStatusFactory.php b/backend/database/factories/InternshipStatusFactory.php new file mode 100644 index 0000000..9826179 --- /dev/null +++ b/backend/database/factories/InternshipStatusFactory.php @@ -0,0 +1,27 @@ + + */ +class InternshipStatusFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'internship_id' => 0, + 'status' => fake()->randomElement(["SUBMITTED", "CONFIRMED", "DENIED", "DEFENDED", "NOT_DEFENDED"]), + 'changed' => fake()->dateTime(), + 'note' => null, + 'modified_by' => 0, + ]; + } +} diff --git a/backend/database/factories/StudentDataFactory.php b/backend/database/factories/StudentDataFactory.php new file mode 100644 index 0000000..31b910a --- /dev/null +++ b/backend/database/factories/StudentDataFactory.php @@ -0,0 +1,26 @@ + + */ +class StudentDataFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'user_id' => 0, + 'address' => fake()->address(), + 'personal_email' => fake()->safeEmail(), + 'study_field' => fake()->randomElement(["AI22m", "AI22b"]), + ]; + } +} diff --git a/backend/database/migrations/2025_10_20_193012_create_internships_table.php b/backend/database/migrations/2025_10_20_193012_create_internships_table.php index 35295a1..1b3f750 100644 --- a/backend/database/migrations/2025_10_20_193012_create_internships_table.php +++ b/backend/database/migrations/2025_10_20_193012_create_internships_table.php @@ -21,8 +21,6 @@ return new class extends Migration $table->enum("semester", ["WINTER", "SUMMER"])->nullable(false); $table->string("position_description")->nullable(false); $table->binary("agreement")->nullable(true); - $table->foreignId("personel_id")->nullable(false)->constrained("users")->onDelete("cascade"); - $table->foreignId("status_id")->nullable(false)->constrained("internship_statuses")->onDelete("cascade"); $table->timestamps(); }); } diff --git a/backend/database/seeders/CompanySeeder.php b/backend/database/seeders/CompanySeeder.php new file mode 100644 index 0000000..d4ce049 --- /dev/null +++ b/backend/database/seeders/CompanySeeder.php @@ -0,0 +1,17 @@ +create([ + $admin = User::factory()->create([ 'name' => 'Test User', 'first_name' => 'Test', 'last_name' => 'User', @@ -22,5 +26,39 @@ class DatabaseSeeder extends Seeder 'phone' => '+421907444555', 'role' => 'ADMIN', ]); + + // create employers and companies + User::factory(10) + ->create([ + 'role' => 'EMPLOYER' + ]) + ->each(function ($user) { + Company::factory()->create([ + 'contact' => $user->id + ]); + }); + + // create students + User::factory(10) + ->create([ + 'role' => 'STUDENT' + ]) + ->each(function ($user) use ($admin) { + StudentData::factory()->create([ + 'user_id' => $user->id + ]); + + $internship = Internship::factory()->create([ + 'user_id' => $user->id, + 'company_id' => Company::inRandomOrder()->value('id'), + ]); + + InternshipStatus::factory()->create([ + 'internship_id' => $internship->id, + 'status' => "SUBMITTED", + 'note' => 'made by seeder', + 'modified_by' => $admin->id, + ]); + }); } } diff --git a/backend/database/seeders/InternshipSeeder.php b/backend/database/seeders/InternshipSeeder.php new file mode 100644 index 0000000..5db6256 --- /dev/null +++ b/backend/database/seeders/InternshipSeeder.php @@ -0,0 +1,17 @@ + Date: Tue, 21 Oct 2025 12:59:48 +0200 Subject: [PATCH 9/9] refactor: remove unused seeder classes for Company, Internship, InternshipStatus, and StudentData --- backend/database/seeders/CompanySeeder.php | 17 ----------------- backend/database/seeders/InternshipSeeder.php | 17 ----------------- .../database/seeders/InternshipStatusSeeder.php | 17 ----------------- backend/database/seeders/StudentDataSeeder.php | 17 ----------------- 4 files changed, 68 deletions(-) delete mode 100644 backend/database/seeders/CompanySeeder.php delete mode 100644 backend/database/seeders/InternshipSeeder.php delete mode 100644 backend/database/seeders/InternshipStatusSeeder.php delete mode 100644 backend/database/seeders/StudentDataSeeder.php diff --git a/backend/database/seeders/CompanySeeder.php b/backend/database/seeders/CompanySeeder.php deleted file mode 100644 index d4ce049..0000000 --- a/backend/database/seeders/CompanySeeder.php +++ /dev/null @@ -1,17 +0,0 @@ -