fix tests

This commit is contained in:
root
2026-06-11 11:46:12 -04:00
parent c91fa2ce4d
commit 5ead80fdc7
1489 changed files with 11349 additions and 10305 deletions
+11 -12
View File
@@ -9,9 +9,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
class WhatsappLinkService
{
public function __construct(private WhatsappContextService $context)
{
}
public function __construct(private WhatsappContextService $context) {}
public function paginate(array $filters): LengthAwarePaginator
{
@@ -29,7 +27,7 @@ class WhatsappLinkService
}
}
if (!empty($filters['class_section_id'])) {
if (! empty($filters['class_section_id'])) {
$query->forSection((int) $filters['class_section_id']);
}
@@ -37,11 +35,11 @@ class WhatsappLinkService
$query->where('active', (int) (bool) $filters['active']);
}
if (!empty($filters['search'])) {
if (! empty($filters['search'])) {
$search = trim((string) $filters['search']);
$query->where(function ($q) use ($search) {
$q->where('class_section_name', 'like', '%' . $search . '%')
->orWhere('invite_link', 'like', '%' . $search . '%')
$q->where('class_section_name', 'like', '%'.$search.'%')
->orWhere('invite_link', 'like', '%'.$search.'%')
->orWhere('class_section_id', $search);
});
}
@@ -50,7 +48,7 @@ class WhatsappLinkService
$sortDir = strtolower((string) ($filters['sort_dir'] ?? 'desc')) === 'asc' ? 'asc' : 'desc';
$allowedSorts = ['class_section_id', 'class_section_name', 'school_year', 'semester', 'active', 'updated_at'];
if (!in_array($sortBy, $allowedSorts, true)) {
if (! in_array($sortBy, $allowedSorts, true)) {
$sortBy = 'updated_at';
}
@@ -63,7 +61,7 @@ class WhatsappLinkService
public function findOrFail(int $id): WhatsappGroupLink
{
$link = WhatsappGroupLink::query()->find($id);
if (!$link) {
if (! $link) {
throw new ModelNotFoundException('WhatsApp group link not found.');
}
@@ -83,7 +81,7 @@ class WhatsappLinkService
$link = WhatsappGroupLink::upsertLinkForSection(
$sectionId,
$sectionName !== '' ? $sectionName : ('Section ' . $sectionId),
$sectionName !== '' ? $sectionName : ('Section '.$sectionId),
$schoolYear,
$semester,
(string) ($payload['invite_link'] ?? ''),
@@ -99,7 +97,7 @@ class WhatsappLinkService
if (array_key_exists('class_section_name', $payload)) {
$name = trim((string) ($payload['class_section_name'] ?? ''));
if ($name === '' && !empty($payload['class_section_id'])) {
if ($name === '' && ! empty($payload['class_section_id'])) {
$name = $this->resolveSectionName((int) $payload['class_section_id']);
}
$payload['class_section_name'] = $name;
@@ -120,6 +118,7 @@ class WhatsappLinkService
private function resolveSectionName(int $sectionId): string
{
$name = ClassSection::getClassSectionNameBySectionId($sectionId);
return $name !== null && $name !== '' ? $name : ('Section ' . $sectionId);
return $name !== null && $name !== '' ? $name : ('Section '.$sectionId);
}
}