fix invalid token
This commit is contained in:
@@ -47,6 +47,49 @@ class ParentAccountService
|
||||
return true;
|
||||
}
|
||||
|
||||
public function administratorParentList(): array
|
||||
{
|
||||
return $this->userModel->where('role', 'parent')->findAll();
|
||||
}
|
||||
|
||||
public function parentById(int $id): ?array
|
||||
{
|
||||
$parent = $this->userModel->find($id);
|
||||
|
||||
return is_array($parent) ? $parent : null;
|
||||
}
|
||||
|
||||
public function createAdministratorParent(array $post): bool|int|string
|
||||
{
|
||||
return $this->userModel->insert([
|
||||
'firstname' => $post['firstname'] ?? null,
|
||||
'lastname' => $post['lastname'] ?? null,
|
||||
'email' => strtolower((string) ($post['email'] ?? '')),
|
||||
'password' => password_hash((string) ($post['password'] ?? ''), PASSWORD_DEFAULT),
|
||||
'role' => 'parent',
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAdministratorParent(int $id, array $post): bool
|
||||
{
|
||||
$data = [
|
||||
'firstname' => $post['firstname'] ?? null,
|
||||
'lastname' => $post['lastname'] ?? null,
|
||||
'email' => strtolower((string) ($post['email'] ?? '')),
|
||||
];
|
||||
|
||||
if (! empty($post['password'])) {
|
||||
$data['password'] = password_hash((string) $post['password'], PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
return (bool) $this->userModel->update($id, $data);
|
||||
}
|
||||
|
||||
public function deleteParent(int $id): bool
|
||||
{
|
||||
return (bool) $this->userModel->delete($id);
|
||||
}
|
||||
|
||||
public function createRelatedUser(array $userData, string $relationToStudent, string $semester, string $schoolYear): int|false
|
||||
{
|
||||
$schoolIdService = new SchoolIdService();
|
||||
|
||||
Reference in New Issue
Block a user