|
@@ -45,30 +45,51 @@ class Objective2Controller extends \BaseController
|
45
|
45
|
return true;
|
46
|
46
|
}
|
47
|
47
|
|
48
|
|
-
|
49
|
|
- private function makeValidator($clean_input)
|
|
48
|
+ //edit == true or edit == false
|
|
49
|
+ private function makeValidator($clean_input, $edit)
|
50
|
50
|
{
|
51
|
51
|
/** Validation rules */
|
52
|
|
- return Validator::make(
|
53
|
|
- array(
|
54
|
|
- 'text' => $clean_input['text'],
|
55
|
52
|
|
56
|
|
- 'outcome_id' => $clean_input['outcome_id'],
|
57
|
|
- 'program_id' => $clean_input['program_id']
|
|
53
|
+ if (!$edit) {
|
|
54
|
+ return Validator::make(
|
|
55
|
+ array(
|
|
56
|
+ 'text' => $clean_input['text'],
|
58
|
57
|
|
59
|
|
- ),
|
60
|
|
- array(
|
61
|
|
- 'text' => 'required|string',
|
|
58
|
+ 'outcome_id' => $clean_input['outcome_id'],
|
|
59
|
+ 'program_id' => $clean_input['program_id']
|
62
|
60
|
|
63
|
|
- 'outcome_id' => 'required|array',
|
64
|
|
- 'program_id' => 'required|array'
|
|
61
|
+ ),
|
|
62
|
+ array(
|
65
|
63
|
|
66
|
|
- )
|
|
64
|
+ 'outcome_id' => 'required|array',
|
|
65
|
+ 'program_id' => 'required|array'
|
|
66
|
+
|
|
67
|
+ )
|
|
68
|
+
|
|
69
|
+ );
|
|
70
|
+ } else {
|
|
71
|
+ return Validator::make(
|
|
72
|
+ array(
|
|
73
|
+ 'text' => $clean_input['text'],
|
|
74
|
+
|
|
75
|
+ 'outcome_id' => $clean_input['outcome_id'],
|
|
76
|
+ 'program_id' => $clean_input['program_id']
|
|
77
|
+
|
|
78
|
+ ),
|
|
79
|
+ array(
|
|
80
|
+ 'text' => 'required|string|unique',
|
67
|
81
|
|
68
|
|
- );
|
|
82
|
+ 'outcome_id' => 'required|array',
|
|
83
|
+ 'program_id' => 'required|array'
|
|
84
|
+
|
|
85
|
+ )
|
|
86
|
+
|
|
87
|
+ );
|
|
88
|
+ }
|
69
|
89
|
}
|
70
|
90
|
|
71
|
91
|
|
|
92
|
+
|
72
|
93
|
private function cleanInput()
|
73
|
94
|
{
|
74
|
95
|
$clean_input = array();
|
|
@@ -78,14 +99,14 @@ class Objective2Controller extends \BaseController
|
78
|
99
|
|
79
|
100
|
$clean_input['outcome_id'] = Input::get('outcome');
|
80
|
101
|
$counter = Input::get('counter') + 0;
|
81
|
|
- Log::info($clean_input);
|
|
102
|
+ // Log::info($clean_input);
|
82
|
103
|
|
83
|
104
|
foreach ($clean_input['outcome_id'] as $index => $outcome_id) {
|
84
|
105
|
$clean_input['outcome_id'][$index] = trim(preg_replace('/\t+/', '', $clean_input['outcome_id'][$index]));
|
85
|
106
|
}
|
86
|
107
|
|
87
|
108
|
$clean_input['program_id'] = Input::get('program_id');
|
88
|
|
- Log::info(Input::get('program_id'));
|
|
109
|
+ // Log::info(Input::get('program_id'));
|
89
|
110
|
|
90
|
111
|
return $clean_input;
|
91
|
112
|
}
|
|
@@ -145,6 +166,8 @@ class Objective2Controller extends \BaseController
|
145
|
166
|
'typ_semester_outcome.id as typ_semester_outcome_id'
|
146
|
167
|
)
|
147
|
168
|
->get();
|
|
169
|
+
|
|
170
|
+
|
148
|
171
|
$json['typ_semester_objectives'] = DB::table('typ_semester_objectives')
|
149
|
172
|
->where('objective_id', Input::get('id'))
|
150
|
173
|
->get();
|
|
@@ -194,7 +217,7 @@ class Objective2Controller extends \BaseController
|
194
|
217
|
$clean_input = $this->cleanInput();
|
195
|
218
|
|
196
|
219
|
/** Validation rules */
|
197
|
|
- $validator = $this->makeValidator($clean_input);
|
|
220
|
+ $validator = $this->makeValidator($clean_input, false);
|
198
|
221
|
|
199
|
222
|
/** If validation fails */
|
200
|
223
|
if ($validator->fails()) {
|
|
@@ -256,6 +279,8 @@ class Objective2Controller extends \BaseController
|
256
|
279
|
if ($objective->save()) {
|
257
|
280
|
$objectiveId = $objective->id;
|
258
|
281
|
|
|
282
|
+ Log::info($clean_input['outcome_id']);
|
|
283
|
+
|
259
|
284
|
|
260
|
285
|
foreach ($clean_input['program_id'] as $program_id) {
|
261
|
286
|
DB::insert("insert into objective_program (objective_id, program_id) values({$objectiveId},{$program_id})");
|
|
@@ -441,7 +466,10 @@ class Objective2Controller extends \BaseController
|
441
|
466
|
//Log::info(print_r($clean_input, true));
|
442
|
467
|
|
443
|
468
|
/** Validation rules */
|
444
|
|
- $validator = $this->makeValidator($clean_input);
|
|
469
|
+ if ($clean_input['text'] == $Objective->text) {
|
|
470
|
+ $validator = $this->makeValidator($clean_input, true);
|
|
471
|
+ } else
|
|
472
|
+ $validator = $this->makeValidator($clean_input, false);
|
445
|
473
|
|
446
|
474
|
/** If validation fails */
|
447
|
475
|
if ($validator->fails()) {
|