Без опису

TransformativeAction.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. class TransformativeAction extends Eloquent
  3. {
  4. protected $table = 'transformative_actions';
  5. public function scopeStatus($query, $semester_id)
  6. {
  7. return $query->join('transformative_action_status')
  8. ->where('trans_id', $this->id)
  9. ->where('semester_id', $semester_id)
  10. ->first();
  11. }
  12. public static function getCategoriesHtml($program_id)
  13. {
  14. $categories = "<option value='0'>Nothing Selected</option>";
  15. $types = DB::table('transformative_actions')
  16. ->select('type_of_TA', 'is_custom')
  17. ->where('type_of_TA', '<>', '')
  18. ->where(function ($query) use (&$program_id) {
  19. $query->whereNull('program_id')
  20. ->orWhere('program_id', $program_id);
  21. })
  22. ->where('by_professor', 0)
  23. ->groupBy('type_of_TA')
  24. ->get();
  25. $optGroupGeneral = "<optgroup label='General Transformative Actions'>";
  26. $optGroupCustom = "<optgroup label ='Program Custom Actions'>";
  27. foreach ($types as $type) {
  28. if ($type->is_custom) {
  29. $optGroupCustom .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '1'>" . $type->type_of_TA . "</option>";
  30. } else {
  31. $optGroupGeneral .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '0'>" . $type->type_of_TA . "</option>";
  32. }
  33. }
  34. $categories .= $optGroupGeneral . '</optgroup>';
  35. $categories .= $optGroupCustom . '</optgroup>';
  36. $categories .= '<option value ="new"> New Type of Transformative Action</option>';
  37. return $categories;
  38. }
  39. }