<?php

namespace App\Services\Parents;

use App\Models\User;

class ParentProfileService
{
    public function getProfile(int $parentId): ?array
    {
        $user = User::query()->find($parentId);
        return $user ? $user->toArray() : null;
    }

    public function updateProfile(int $parentId, array $payload): array
    {
        $user = User::query()->findOrFail($parentId);
        $user->update([
            'firstname' => $payload['firstname'],
            'lastname' => $payload['lastname'],
            'cellphone' => $payload['cellphone'],
            'address_street' => $payload['address_street'],
            'city' => $payload['city'],
            'state' => $payload['state'],
            'zip' => $payload['zip'],
        ]);

        return $user->toArray();
    }
}
