Refactor various services and models for improved type handling and configuration management

This commit is contained in:
SitiWeb
2026-04-30 01:54:49 +02:00
parent f939133fe0
commit 39bdba2dfb
11 changed files with 40 additions and 33 deletions

View File

@@ -125,7 +125,7 @@ class HelpdeskImportService
continue;
}
if (! $dryRun && $parentId !== null) {
if (! $dryRun) {
$childModel = Category::query()->updateOrCreate(
['external_id' => (int) $child['id']],
['name' => (string) $child['title'], 'slug' => (string) $child['slug'], 'parent_id' => $parentId]
@@ -179,13 +179,15 @@ class HelpdeskImportService
foreach ($sources as $source) {
try {
$html = $source['html'] ?? $this->fetch($source['url']);
$html = array_key_exists('html', $source)
? (string) $source['html']
: $this->fetch((string) $source['url']);
} catch (\Throwable) {
continue;
}
preg_match_all('/https:\/\/www\.internettoday\.nl\/helpdesk\/(\d+)-[a-z0-9\-]+/i', $html, $matches);
foreach (($matches[0] ?? []) as $match) {
foreach ($matches[0] as $match) {
$url = strtolower($match);
if (! isset($result[$url])) {
$result[$url] = [