fix gitlab tests
This commit is contained in:
@@ -9,7 +9,9 @@ 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
|
||||
{
|
||||
@@ -27,7 +29,7 @@ class WhatsappLinkService
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($filters['class_section_id'])) {
|
||||
if (!empty($filters['class_section_id'])) {
|
||||
$query->forSection((int) $filters['class_section_id']);
|
||||
}
|
||||
|
||||
@@ -35,11 +37,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);
|
||||
});
|
||||
}
|
||||
@@ -48,7 +50,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';
|
||||
}
|
||||
|
||||
@@ -61,7 +63,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.');
|
||||
}
|
||||
|
||||
@@ -81,7 +83,7 @@ class WhatsappLinkService
|
||||
|
||||
$link = WhatsappGroupLink::upsertLinkForSection(
|
||||
$sectionId,
|
||||
$sectionName !== '' ? $sectionName : ('Section '.$sectionId),
|
||||
$sectionName !== '' ? $sectionName : ('Section ' . $sectionId),
|
||||
$schoolYear,
|
||||
$semester,
|
||||
(string) ($payload['invite_link'] ?? ''),
|
||||
@@ -97,7 +99,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;
|
||||
@@ -118,7 +120,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user