Skip to content

Commit

Permalink
[Bug] if course type is foundation it cant be created db issue 210 (#211
Browse files Browse the repository at this point in the history
)
  • Loading branch information
NuwanJ authored Nov 5, 2024
1 parent 1008354 commit b49fac2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Domains/AcademicProgram/AcademicProgram.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static function getVersions($academicProgram = null): array
public static function getTypes(): array
{
return [
'Found' => 'Foundation',
'Foundation' => 'Foundation',
'Core' => 'Core',
'GE' => 'General Elective',
'TE' => 'Technical Elective'
];
}
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Backend/CreateCourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function messages()
'semester.required' => 'Please select a semester.',
'version.required' => 'Please provide a curriculum.',
'type.required' => 'Please select a course type.',
'type.in' => 'The course type must be Core, GE, or TE.',
'type.in' => 'The course type must be Foundation, Core, GE, or TE.',
'code.required' => 'Please provide a course code.',
'code.unique' => 'This course code is already in use.',
'name.required' => 'Please provide a course name.',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Backend/EditCourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function messages()
'semester.required' => 'Please select a semester.',
'version.required' => 'Please provide a curriculum.',
'type.required' => 'Please select a course type.',
'type.in' => 'The course type must be Core, GE, or TE.',
'type.in' => 'The course type must be Foundation, Core, GE, or TE.',
'code.required' => 'Please provide a course code.',
'name.required' => 'Please provide a course name.',
'credits.required' => 'Please specify the number of credits.',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Migrations\Migration;
use App\Domains\AcademicProgram\Course\Models\Course;

class AlterCourseTypeEnumColumnUpdate extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Update the enum field with new types
if (Schema::getConnection()->getDriverName() !== 'sqlite') {
$enumValues = "'" . implode("', '", array_keys(Course::getTypes())) . "'";
DB::statement("ALTER TABLE courses MODIFY COLUMN type ENUM($enumValues)");
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Nothing here
}
}

0 comments on commit b49fac2

Please sign in to comment.