|
@@ -13,7 +13,7 @@ class CourseTableSeeder extends Seeder {
|
13
|
13
|
$time_start = microtime(true);
|
14
|
14
|
|
15
|
15
|
// Open file
|
16
|
|
- if($file = fopen('app/database/csv/courses.csv', 'r'))
|
|
16
|
+ if($file = fopen('app/database/csv/cursos.csv', 'r'))
|
17
|
17
|
{
|
18
|
18
|
// Initialize count variables
|
19
|
19
|
$read = 0;
|
|
@@ -22,7 +22,7 @@ class CourseTableSeeder extends Seeder {
|
22
|
22
|
$error = 0;
|
23
|
23
|
|
24
|
24
|
// Read each row
|
25
|
|
- while($data = fgetcsv($file, 5000, "|")) // se cambio delimitador para evitar problemas con nombres separados del apellido por coma
|
|
25
|
+ while($data = fgetcsv($file, 5000)) // se cambio delimitador para evitar problemas con nombres separados del apellido por coma
|
26
|
26
|
{
|
27
|
27
|
// Add read count
|
28
|
28
|
$read++;
|
|
@@ -31,13 +31,14 @@ class CourseTableSeeder extends Seeder {
|
31
|
31
|
try
|
32
|
32
|
{
|
33
|
33
|
// Get row info
|
34
|
|
- $name = $data[6];
|
35
|
|
- $code = trim(substr($data[0], 0, 4));
|
36
|
|
- $number = trim(substr($data[0], 4, 4));
|
37
|
|
- $section = trim(substr($data[0], 8, 3));
|
38
|
|
- $user_id = User::select('id')->where('ssn', trim($data[14]))->first();
|
39
|
|
- $semester_id = Semester::select('id')->where('code', strtoupper(trim($data[2])))->first();
|
40
|
|
- $program_code = trim($data[7]);
|
|
34
|
+ $name = $data[8];
|
|
35
|
+ $code = trim(substr($data[1], 0, 4));
|
|
36
|
+ $number = trim(substr($data[1], 4, 4));
|
|
37
|
+ $section = trim(substr($data[1], 8, 3));
|
|
38
|
+ $user_id = User::select('id')->where('ssn', trim($data[11]))->first();
|
|
39
|
+ $semester_id = Semester::select('id')->where('code', strtoupper(trim($data[3])))->first();
|
|
40
|
+ $program_code = trim($data[9]);
|
|
41
|
+ $modality = trim($data[5]);
|
41
|
42
|
|
42
|
43
|
// If any row is empty, raise an exception
|
43
|
44
|
if($name=='' || $code=='' || $number=='' || $section=='' || trim($data[14])=='' || trim($data[2])=='')
|
|
@@ -93,6 +94,7 @@ class CourseTableSeeder extends Seeder {
|
93
|
94
|
'code' => $code,
|
94
|
95
|
'number' => $number,
|
95
|
96
|
'section' => $section,
|
|
97
|
+ 'modality' => $modality,
|
96
|
98
|
'program_id' => $program_id,
|
97
|
99
|
'user_id' => $user_id,
|
98
|
100
|
'updated_at' => date("Y-m-d H:i:s", time())
|
|
@@ -110,6 +112,7 @@ class CourseTableSeeder extends Seeder {
|
110
|
112
|
'code' => $code,
|
111
|
113
|
'number' => $number,
|
112
|
114
|
'section' => $section,
|
|
115
|
+ 'modality' => $modality,
|
113
|
116
|
'program_id' => $program_id,
|
114
|
117
|
'user_id' => $user_id,
|
115
|
118
|
'semester_id' => $semester_id
|