Ver código fonte

permitir que cursos de otros programas puedan ser usados en un plan

Carlos J Corrada Bravo 2 anos atrás
pai
commit
f172cc120b

+ 14
- 0
app/controllers/ThreeYearPlanController.php Ver arquivo

@@ -444,12 +444,26 @@ class ThreeYearPlanController extends \BaseController
444 444
 
445 445
           $semesters_->selected_objectives = array();
446 446
           foreach ($result_objectives as $objectives_) {
447
+//             $result_courses = DB::table('courses')
448
+//               ->where('courses.program_id', $program_id)
449
+//               ->select('courses.id as course_id', 'courses.name', 'courses.code', 'courses.number', 'courses.program_id')
450
+//               ->orderBy('courses.number', 'asc')
451
+//               ->groupBy('courses.name', 'courses.code')
452
+//               ->get();
453
+
447 454
             $result_courses = DB::table('courses')
448 455
               ->where('courses.program_id', $program_id)
456
+              ->orWhereIn('courses.program_id', function ($q) use ($program_id){
457
+              		$q->select('other_program_id')
458
+              		  ->from('other_programs_courses_typ')
459
+              		  ->where('program_id',$program_id);	
460
+              })
449 461
               ->select('courses.id as course_id', 'courses.name', 'courses.code', 'courses.number', 'courses.program_id')
462
+              ->orderBy('courses.code', 'asc')
450 463
               ->orderBy('courses.number', 'asc')
451 464
               ->groupBy('courses.name', 'courses.code')
452 465
               ->get();
466
+
453 467
             #los cursos resultantes creo que deberian ser: todos los que se estan dando en mi programa
454 468
 
455 469
             $objectives_->available_courses = array();

+ 45
- 0
app/database/migrations/2022_02_28_115623_create_other_programs_courses_typ_table.php Ver arquivo

@@ -0,0 +1,45 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateOtherProgramsCoursesTypTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		//
16
+		Schema::create('other_programs_courses_typ', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('program_id')->unsigned();
19
+			$table->integer('other_program_id')->unsigned();
20
+			$table->foreign('program_id')
21
+				->references('id')
22
+				->on('programs')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+			$table->foreign('other_program_id')
26
+				->references('id')
27
+				->on('programs')
28
+				->onDelete('cascade')
29
+				->onUpdate('cascade');
30
+		});
31
+	}
32
+
33
+	/**
34
+	 * Reverse the migrations.
35
+	 *
36
+	 * @return void
37
+	 */
38
+	public function down()
39
+	{
40
+		//
41
+		Schema::drop('other_programs_courses_typ');
42
+
43
+	}
44
+
45
+}