add test batches

This commit is contained in:
root
2026-06-08 23:45:55 -04:00
parent c792b8be05
commit 8d4d610b82
1480 changed files with 22587 additions and 10762 deletions
+26 -23
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use App\Models\BaseModel;
class WhatsappGroupLink extends BaseModel
{
@@ -16,14 +17,13 @@ class WhatsappGroupLink extends BaseModel
'invite_link',
'active',
];
public $timestamps = true; // requires created_at/updated_at
protected $casts = [
'class_section_id' => 'integer',
'active' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'active' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/* ============================================================
@@ -52,7 +52,7 @@ class WhatsappGroupLink extends BaseModel
if ($allowNullSemester) {
return $q->where(function (Builder $w) use ($sem) {
$w->where('semester', $sem)
->orWhereNull('semester');
->orWhereNull('semester');
});
}
@@ -72,7 +72,7 @@ class WhatsappGroupLink extends BaseModel
public function scopeHasInviteLink(Builder $q): Builder
{
return $q->whereNotNull('invite_link')
->where('invite_link', '!=', '');
->where('invite_link', '!=', '');
}
/* ============================================================
@@ -83,11 +83,11 @@ class WhatsappGroupLink extends BaseModel
/**
* Get the link for a specific section in a specific term.
*
* @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 bool $onlyActive If true, require active=1.
* @param bool $allowNullSemester If true, accept rows with semester IS NULL as well.
* @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 bool $onlyActive If true, require active=1.
* @param bool $allowNullSemester If true, accept rows with semester IS NULL as well.
*/
public static function getLinkForSection(
int $sectionId,
@@ -114,8 +114,11 @@ class WhatsappGroupLink extends BaseModel
/**
* Get all links for a term.
*
* @param bool|null $onlyActive true: active only, false: inactive only, null: both
* @param bool $allowNullSemester If true, include rows with semester IS NULL.
* @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.
*
* @return array<WhatsappGroupLink>
*/
public static function getAllForTerm(
@@ -154,16 +157,16 @@ class WhatsappGroupLink extends BaseModel
): self {
$payload = [
'class_section_name' => $sectionName,
'invite_link' => trim($inviteLink),
'active' => $active ? 1 : 0,
'invite_link' => trim($inviteLink),
'active' => $active ? 1 : 0,
];
// NOTE: semester is part of the uniqueness key like your legacy version.
return static::query()->updateOrCreate(
[
'class_section_id' => $sectionId,
'school_year' => trim($year),
'semester' => trim($sem),
'school_year' => trim($year),
'semester' => trim($sem),
],
$payload
);
@@ -179,12 +182,12 @@ class WhatsappGroupLink extends BaseModel
$req = $updating ? 'sometimes' : 'required';
return [
'class_section_id' => [$req, 'integer', 'min:1'],
'class_section_id' => [$req, 'integer', 'min:1'],
'class_section_name' => [$req, 'string', 'max:255'],
'school_year' => [$req, 'string', 'max:20'],
'semester' => ['nullable', 'string', 'max:20'],
'invite_link' => [$req, 'string', 'max:2000'],
'active' => ['nullable', 'boolean'],
'school_year' => [$req, 'string', 'max:20'],
'semester' => ['nullable', 'string', 'max:20'],
'invite_link' => [$req, 'string', 'max:2000'],
'active' => ['nullable', 'boolean'],
];
}
}
}