fix registration issue and split parent controller into services
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Parents;
|
||||
|
||||
use CodeIgniter\Database\BaseConnection;
|
||||
|
||||
class ParentPaymentService
|
||||
{
|
||||
public function __construct(private readonly BaseConnection $db)
|
||||
{
|
||||
}
|
||||
|
||||
public function invoicesForParent(int $parentId, bool $includeRegisteredKids = false): array
|
||||
{
|
||||
if ($parentId <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$select = $includeRegisteredKids ? 'invoices.*, registeredKids' : '*';
|
||||
|
||||
return $this->db->table('invoices')
|
||||
->select($select)
|
||||
->where('parent_id', $parentId)
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function markTuitionPaidForParent(int $parentId): void
|
||||
{
|
||||
if ($parentId <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->db->table('students')
|
||||
->where('parent_id', $parentId)
|
||||
->update(['tuition_paid' => 1]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user