Phase 4 work order profile depth

This commit is contained in:
Codex
2026-07-10 13:24:07 -05:00
parent 084b945e75
commit 24fd8c0c5c
21 changed files with 1031 additions and 110 deletions
@@ -71,8 +71,11 @@ class ProviderProfileController extends Controller
'bio' => ['nullable', 'string'],
'service_area' => ['nullable', 'string', 'max:255'],
'skills' => ['nullable', 'string'],
'services_text' => ['nullable', 'string'],
'tools' => ['nullable', 'string'],
'tool_inventory_text' => ['nullable', 'string'],
'certifications' => ['nullable', 'string'],
'certification_records_text' => ['nullable', 'string'],
'insurance_status' => ['nullable', 'string', 'max:255'],
'rate_card' => ['nullable', 'string'],
'travel_policy' => ['nullable', 'string'],
@@ -80,9 +83,19 @@ class ProviderProfileController extends Controller
'website_url' => ['nullable', 'url', 'max:255'],
'phone' => ['nullable', 'string', 'max:255'],
'public_contact' => ['nullable', 'boolean'],
'profile_visibility' => ['nullable', 'array'],
'profile_visibility.*' => ['nullable', 'boolean'],
'private_notes' => ['nullable', 'string'],
]);
$data['public_contact'] = $request->boolean('public_contact');
$data['services'] = $this->linesToRecords($data['services_text'] ?? '', ['name', 'level']);
$data['tool_inventory'] = $this->linesToRecords($data['tool_inventory_text'] ?? '', ['name', 'category']);
$data['certification_records'] = $this->linesToRecords($data['certification_records_text'] ?? '', ['name', 'issuer']);
$data['profile_visibility'] = $this->normalizeVisibility($request, [
'bio', 'services', 'tools', 'certifications', 'rate_card', 'availability', 'imports',
]);
unset($data['services_text'], $data['tool_inventory_text'], $data['certification_records_text']);
$request->user()->providerProfile()->updateOrCreate(
['user_id' => $request->user()->id],
@@ -98,4 +111,21 @@ class ProviderProfileController extends Controller
'profile' => $provider->load('user', 'externalImports.attachments', 'attachments', 'ratings.user'),
]);
}
private function linesToRecords(string $text, array $keys): array
{
return collect(preg_split('/\r\n|\r|\n/', $text))
->map(fn (string $line): array => array_pad(array_map('trim', explode('|', $line, count($keys))), count($keys), null))
->filter(fn (array $parts): bool => (bool) ($parts[0] ?? null))
->map(fn (array $parts): array => collect($keys)->mapWithKeys(fn (string $key, int $index): array => [$key => $parts[$index] ?? null])->all())
->values()
->all();
}
private function normalizeVisibility(Request $request, array $fields): array
{
return collect($fields)
->mapWithKeys(fn (string $field): array => [$field => $request->boolean("profile_visibility.$field")])
->all();
}
}