security fix and fix parent pages
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -36,7 +36,7 @@ class SchoolCalendarMutationService
|
||||
|
||||
public function update(CalendarEvent $event, array $payload, array $targets = []): array
|
||||
{
|
||||
$data = $this->normalizePayload($payload);
|
||||
$data = $this->normalizePayload($payload, true);
|
||||
|
||||
try {
|
||||
DB::transaction(function () use ($event, $data) {
|
||||
@@ -69,8 +69,41 @@ class SchoolCalendarMutationService
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizePayload(array $payload): array
|
||||
private function normalizePayload(array $payload, bool $partial = false): array
|
||||
{
|
||||
if ($partial) {
|
||||
$data = [];
|
||||
foreach ([
|
||||
'title',
|
||||
'description',
|
||||
'event_type',
|
||||
'date',
|
||||
'notify_parent',
|
||||
'notify_teacher',
|
||||
'notify_admin',
|
||||
'no_school',
|
||||
'school_year',
|
||||
'semester',
|
||||
] as $key) {
|
||||
if (! array_key_exists($key, $payload)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($key, ['notify_parent', 'notify_teacher', 'notify_admin', 'no_school'], true)) {
|
||||
$data[$key] = ! empty($payload[$key]) ? 1 : 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[$key] = $payload[$key];
|
||||
}
|
||||
|
||||
if (! CalendarEvent::supportsEventType()) {
|
||||
unset($data['event_type']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => (string) ($payload['title'] ?? ''),
|
||||
'description' => $payload['description'] ?? null,
|
||||
|
||||
Reference in New Issue
Block a user