fix db tables to have school year
This commit is contained in:
@@ -11,7 +11,6 @@ class WhatsappGroupLinkModel extends Model
|
||||
'class_section_id',
|
||||
'class_section_name',
|
||||
'school_year',
|
||||
'semester',
|
||||
'invite_link',
|
||||
'active',
|
||||
];
|
||||
@@ -22,9 +21,9 @@ class WhatsappGroupLinkModel extends Model
|
||||
*
|
||||
* @param int $sectionId Class/section code (not PK).
|
||||
* @param string $year School year, e.g. "2025-2026".
|
||||
* @param string $sem Semester, e.g. "Fall".
|
||||
* @param string $sem Deprecated/ignored; links are scoped by school year.
|
||||
* @param bool $onlyActive If true, require active=1.
|
||||
* @param bool $allowNullSemester If true, accept rows with semester IS NULL as well.
|
||||
* @param bool $allowNullSemester Deprecated/ignored.
|
||||
*/
|
||||
public function getLinkForSection(
|
||||
int $sectionId,
|
||||
@@ -40,17 +39,6 @@ class WhatsappGroupLinkModel extends Model
|
||||
->where('class_section_id', $sectionId)
|
||||
->where('school_year', $year);
|
||||
|
||||
if ($sem !== '') {
|
||||
if ($allowNullSemester) {
|
||||
$b = $b->groupStart()
|
||||
->where('semester', $sem)
|
||||
->orWhere('semester IS NULL', null, false)
|
||||
->groupEnd();
|
||||
} else {
|
||||
$b = $b->where('semester', $sem);
|
||||
}
|
||||
}
|
||||
|
||||
if ($onlyActive) {
|
||||
$b = $b->where('active', 1);
|
||||
}
|
||||
@@ -70,7 +58,7 @@ class WhatsappGroupLinkModel extends Model
|
||||
* @param string $year
|
||||
* @param string $sem
|
||||
* @param bool|null $onlyActive true: active only, false: inactive only, null: both
|
||||
* @param bool $allowNullSemester If true, include rows with semester IS NULL.
|
||||
* @param bool $allowNullSemester Deprecated/ignored.
|
||||
*/
|
||||
public function getAllForTerm(
|
||||
string $year,
|
||||
@@ -84,17 +72,6 @@ class WhatsappGroupLinkModel extends Model
|
||||
$b = $this->asArray()
|
||||
->where('school_year', $year);
|
||||
|
||||
if ($sem !== '') {
|
||||
if ($allowNullSemester) {
|
||||
$b = $b->groupStart()
|
||||
->where('semester', $sem)
|
||||
->orWhere('semester IS NULL', null, false)
|
||||
->groupEnd();
|
||||
} else {
|
||||
$b = $b->where('semester', $sem);
|
||||
}
|
||||
}
|
||||
|
||||
if ($onlyActive === true) {
|
||||
$b = $b->where('active', 1);
|
||||
} elseif ($onlyActive === false) {
|
||||
@@ -122,7 +99,6 @@ class WhatsappGroupLinkModel extends Model
|
||||
'class_section_id' => $sectionId,
|
||||
'class_section_name' => $sectionName,
|
||||
'school_year' => trim($year),
|
||||
'semester' => trim($sem),
|
||||
'invite_link' => trim($inviteLink),
|
||||
'active' => $active ? 1 : 0,
|
||||
];
|
||||
@@ -131,7 +107,6 @@ class WhatsappGroupLinkModel extends Model
|
||||
$existing = $this->asArray()
|
||||
->where('class_section_id', $sectionId)
|
||||
->where('school_year', $payload['school_year'])
|
||||
->where('semester', $payload['semester'])
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
|
||||
Reference in New Issue
Block a user