update controllers logic

This commit is contained in:
root
2026-04-23 00:04:35 -04:00
parent 1977a513df
commit ca4ba272fc
353 changed files with 13402 additions and 1301 deletions
@@ -4,13 +4,15 @@ namespace App\Services\Frontend;
use App\Models\Invoice;
use App\Models\StudentClass;
use App\Services\Parents\PrimaryParentUserResolver;
use Illuminate\Support\Facades\DB;
class LandingPageParentDashboardService
{
public function __construct(private LandingPageContextService $context)
{
}
public function __construct(
private LandingPageContextService $context,
private PrimaryParentUserResolver $primaryParentResolver,
) {}
public function summary(int $parentUserId, string $userType): array
{
@@ -18,7 +20,7 @@ class LandingPageParentDashboardService
$schoolYear = (string) ($context['school_year'] ?? '');
$semester = (string) ($context['semester'] ?? '');
$parentId = $this->resolveParentId($parentUserId, $userType);
$parentId = $this->primaryParentResolver->resolveFromCredentials($parentUserId, $userType);
if (!$parentId) {
return [
'ok' => false,
@@ -89,31 +91,6 @@ class LandingPageParentDashboardService
];
}
private function resolveParentId(int $userId, string $userType): ?int
{
if ($userType === 'primary') {
return $userId;
}
if ($userType === 'secondary') {
$row = DB::table('parents')
->select('parent_id')
->where('secondparent_user_id', $userId)
->first();
return $row ? (int) $row->parent_id : null;
}
if ($userType === 'tertiary') {
$row = DB::table('authorized_users')
->select('user_id as parent_id')
->where('authorized_user_id', $userId)
->first();
return $row ? (int) $row->parent_id : null;
}
return null;
}
private function notificationsForParent(int $parentId): array
{
return DB::table('notifications')