Last active
November 26, 2022 17:37
-
-
Save tisuchi/f434242e68cef9de5621ebb7e3f0b4c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function upgradeMgmlCycle($studentInfo) | |
{ | |
if ($studentInfo->cycle_end >= now()->today()) { | |
return $studentInfo; | |
} | |
if (!$studentInfo->cycle >= $studentInfo->mgml_syllab_cycle) { | |
$studentInfo->cycle = $studentInfo->cycle + 1; | |
$studentInfo->cycle_start = now()->firstOfMonth(); | |
$studentInfo->cycle_end = $this->addMonthsAndGettLastDayOfMonth($studentInfo->mgml_syllab_unit_per_cycle - 1); | |
return $studentInfo; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mgml_cycle_scores | |
// - student: belongsTo | |
// students | |
// - mgml_cycle_scores: hasMany | |
// - center: belongsTo | |
// center | |
// students: hasMany | |
// Other approach | |
// 1 | |
Student::with(['center', 'mgml_cycle_scores']) | |
->Active() | |
->whereHas('center', function ($query) { | |
$query->where('center_type_id', $this->mgml_center_type_id); | |
}) | |
->whereHas('mgml_cycle_scores', function ($query) { | |
$query->groupBy('subject_id', 'student_id'); | |
}) | |
->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment