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 @@ +