fix parent pages and teachers and admin
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -34,6 +34,7 @@ class PaymentManualService
|
||||
}
|
||||
|
||||
$parentData = null;
|
||||
$parentMatches = [];
|
||||
$students = [];
|
||||
$payments = [];
|
||||
$invoices = [];
|
||||
@@ -47,6 +48,14 @@ class PaymentManualService
|
||||
$builder->where(function ($q) use ($searchTerm, $searchClean, $searchFormatted) {
|
||||
$q->where('email', $searchTerm);
|
||||
|
||||
if (ctype_digit($searchTerm)) {
|
||||
$q->orWhere('id', (int) $searchTerm);
|
||||
}
|
||||
|
||||
$q->orWhereRaw("CONCAT_WS(' ', firstname, lastname) LIKE ?", ['%'.$searchTerm.'%'])
|
||||
->orWhere('firstname', 'like', '%'.$searchTerm.'%')
|
||||
->orWhere('lastname', 'like', '%'.$searchTerm.'%');
|
||||
|
||||
if (! empty($searchClean)) {
|
||||
if (strlen($searchClean) === 10) {
|
||||
$formattedPhone = substr($searchClean, 0, 3).'-'.substr($searchClean, 3, 3).'-'.substr($searchClean, 6, 4);
|
||||
@@ -62,11 +71,19 @@ class PaymentManualService
|
||||
if (! empty($searchFormatted)) {
|
||||
$q->orWhere('cellphone', $searchFormatted);
|
||||
}
|
||||
});
|
||||
})
|
||||
->orderByRaw('LOWER(firstname)')
|
||||
->orderByRaw('LOWER(lastname)')
|
||||
->orderByRaw('LOWER(email)')
|
||||
->limit(20);
|
||||
|
||||
$parent = (array) $builder->first();
|
||||
$parentRows = $builder->get()
|
||||
->map(fn ($row) => $this->sanitizeParentRow((array) $row))
|
||||
->all();
|
||||
$parentMatches = $parentRows;
|
||||
|
||||
$parent = $parentRows[0] ?? [];
|
||||
if (! empty($parent)) {
|
||||
unset($parent['password']);
|
||||
$parentData = $parent;
|
||||
$parentId = (int) ($parent['id'] ?? 0);
|
||||
|
||||
@@ -100,6 +117,7 @@ class PaymentManualService
|
||||
|
||||
return [
|
||||
'parent' => $parentData,
|
||||
'parent_matches' => $parentMatches,
|
||||
'students' => $students,
|
||||
'payments' => $payments,
|
||||
'invoices' => $invoices,
|
||||
@@ -133,7 +151,7 @@ class PaymentManualService
|
||||
$params[] = '%'.$digits.'%';
|
||||
}
|
||||
|
||||
$sql .= ') ORDER BY lastname, firstname LIMIT 20';
|
||||
$sql .= ') ORDER BY LOWER(firstname), LOWER(lastname), LOWER(email) LIMIT 20';
|
||||
|
||||
$rows = DB::select($sql, $params);
|
||||
|
||||
@@ -156,6 +174,13 @@ class PaymentManualService
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function sanitizeParentRow(array $parent): array
|
||||
{
|
||||
unset($parent['password'], $parent['remember_token']);
|
||||
|
||||
return $parent;
|
||||
}
|
||||
|
||||
public function recordPayment(
|
||||
int $invoiceId,
|
||||
float $amount,
|
||||
|
||||
Reference in New Issue
Block a user