12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
-
- class TransformativeAction extends Eloquent
- {
- protected $table = 'transformative_actions';
-
- public function scopeStatus($query, $semester_id)
- {
- return $query->join('transformative_action_status')
- ->where('trans_id', $this->id)
- ->where('semester_id', $semester_id)
- ->first();
- }
-
- public static function getCategoriesHtml($program_id)
- {
- $categories = "<option value='0'>Nothing Selected</option>";
-
- $types = DB::table('transformative_actions')
- ->select('type_of_TA', 'is_custom')
- ->where('type_of_TA', '<>', '')
- ->where(function ($query) use (&$program_id) {
- $query->whereNull('program_id')
- ->orWhere('program_id', $program_id);
- })
- ->where('by_professor', 0)
- ->groupBy('type_of_TA')
- ->get();
- $optGroupGeneral = "<optgroup label='General Transformative Actions'>";
- $optGroupCustom = "<optgroup label ='Program Custom Actions'>";
- foreach ($types as $type) {
-
- if ($type->is_custom) {
- $optGroupCustom .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '1'>" . $type->type_of_TA . "</option>";
- } else {
- $optGroupGeneral .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '0'>" . $type->type_of_TA . "</option>";
- }
- }
- $categories .= $optGroupGeneral . '</optgroup>';
- $categories .= $optGroupCustom . '</optgroup>';
-
-
- $categories .= '<option value ="new"> New Type of Transformative Action</option>';
- return $categories;
- }
- }
|