Нет описания

Objective.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. use Illuminate\Database\Eloquent\SoftDeletingTrait;
  3. class Objective extends Eloquent
  4. {
  5. use SoftDeletingTrait;
  6. protected $fillable = array('text', 'outcome_id', 'active');
  7. protected $table = 'objectives';
  8. /**
  9. * Return the program that the objective belongs to
  10. *
  11. * @return Illuminate\Database\Eloquent\Model
  12. */
  13. public function program()
  14. {
  15. return $this->belongsTo('Program');
  16. }
  17. /**
  18. * Return the outcomes that the objective belongs to
  19. *
  20. * @return Illuminate\Database\Eloquent\Model
  21. */
  22. //Must have typ_semester_objective_id, program_id,semester_id to work
  23. //funciona con Outcome::getObjectivesReport
  24. //Es como la imagen suelta por el app llamada, tabla_estudiantes.jpg
  25. //
  26. public static function getPlanReport($objective)
  27. {
  28. $course_codes = DB::table('typ_semester_courses')
  29. ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  30. ->where('typ_semester_objective_id', $objective->typ_semester_objective_id)
  31. ->where('courses.program_id', $objective->program_id)
  32. ->select('courses.code', 'courses.number', 'typ_semester_courses.id as typ_semester_course_id', DB::raw("'{$objective->semester_id}' as semester_id"), "courses.program_id")
  33. ->get();
  34. Log::info($course_codes);
  35. //$course_codes['studentPerOutcome'] = array();
  36. foreach ($course_codes as $course_code) {
  37. $course_code->students = Course::getStudentReportForOutcome($course_code);
  38. Log::info(array($course_code));
  39. $course_code->criteria = Course::getCriteriaPlanReport($course_code);
  40. }
  41. return $course_codes;
  42. }
  43. public function outcomes()
  44. {
  45. return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
  46. }
  47. public function outcome()
  48. {
  49. return $this->belongsTo('Outcome');
  50. }
  51. /**
  52. * Return the program that the objective belongs to
  53. *
  54. * @return Illuminate\Database\Eloquent\Model
  55. */
  56. public function outcome_id()
  57. {
  58. return $this->hasMany('Objective_Outcome', 'objective_id');
  59. }
  60. }