$data */ protected function handleRecordCreation(array $data): Model { $service = app(PageService::class); $content = SectionEditor::fromEditorState($data['sections'] ?? []); try { return DB::transaction(function () use ($service, $data, $content): Page { $page = Page::query()->create([ 'path' => $service->availablePath($data['path']), ]); $service->saveRevision( $page, $content, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user(), ); app(PillarService::class)->assignPages($page, array_map(intval(...), $data['pillars'] ?? [])); return $page; }); } catch (ValidationException $exception) { SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []); throw ValidationException::withMessages( SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []), ); } } protected function getRedirectUrl(): string { return static::getResource()::getUrl('edit', ['record' => $this->getRecord()]); } }