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
+20 -2
View File
@@ -9,11 +9,22 @@ use Illuminate\Database\Eloquent\Model;
#[Fillable([
'user_id', 'company_name', 'headline', 'description', 'service_categories',
'hiring_regions', 'vendor_onboarding', 'payment_terms', 'website_url',
'contact_email', 'public_contact',
'hiring_regions', 'hiring_policies', 'locations', 'vendor_onboarding',
'payment_terms', 'website_url', 'contact_email', 'public_contact',
'profile_visibility', 'private_notes',
])]
class BuyerProfile extends Model
{
protected function casts(): array
{
return [
'hiring_policies' => 'array',
'locations' => 'array',
'profile_visibility' => 'array',
'public_contact' => 'boolean',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
@@ -28,4 +39,11 @@ class BuyerProfile extends Model
{
return $this->morphMany(Rating::class, 'rateable');
}
public function visible(string $field): bool
{
$visibility = $this->profile_visibility ?? [];
return (bool) ($visibility[$field] ?? true);
}
}
+21 -2
View File
@@ -10,11 +10,23 @@ use Illuminate\Database\Eloquent\Model;
#[Fillable([
'user_id', 'business_name', 'headline', 'bio', 'service_area', 'skills',
'tools', 'certifications', 'insurance_status', 'rate_card', 'travel_policy',
'availability_notes', 'website_url', 'phone', 'public_contact',
'services', 'tools', 'tool_inventory', 'certifications', 'certification_records',
'insurance_status', 'rate_card', 'travel_policy', 'availability_notes',
'website_url', 'phone', 'public_contact', 'profile_visibility', 'private_notes',
])]
class ProviderProfile extends Model
{
protected function casts(): array
{
return [
'services' => 'array',
'tool_inventory' => 'array',
'certification_records' => 'array',
'profile_visibility' => 'array',
'public_contact' => 'boolean',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
@@ -34,4 +46,11 @@ class ProviderProfile extends Model
{
return $this->morphMany(Rating::class, 'rateable');
}
public function visible(string $field): bool
{
$visibility = $this->profile_visibility ?? [];
return (bool) ($visibility[$field] ?? true);
}
}
+43 -1
View File
@@ -10,7 +10,9 @@ use Illuminate\Database\Eloquent\Model;
#[Fillable([
'job_post_id', 'buyer_id', 'provider_id', 'accepted_quote_id', 'status',
'status_history', 'agreed_terms', 'deliverables_checklist', 'completion_notes',
'status_history', 'agreed_terms', 'deliverables_checklist', 'scheduled_at',
'appointment_window', 'checklist_items', 'checklist_completed', 'required_evidence',
'evidence_rules', 'change_requests', 'completion_notes',
'en_route_at', 'on_site_at', 'started_at', 'completed_at', 'approved_at', 'closed_at',
])]
class WorkOrder extends Model
@@ -36,6 +38,11 @@ class WorkOrder extends Model
{
return [
'status_history' => 'array',
'scheduled_at' => 'datetime',
'checklist_items' => 'array',
'checklist_completed' => 'array',
'evidence_rules' => 'array',
'change_requests' => 'array',
'en_route_at' => 'datetime',
'on_site_at' => 'datetime',
'started_at' => 'datetime',
@@ -94,4 +101,39 @@ class WorkOrder extends Model
{
return in_array($status, self::ALLOWED_TRANSITIONS[$this->status] ?? [], true);
}
public function checklistItems(): array
{
if (is_array($this->checklist_items) && $this->checklist_items !== []) {
return array_values(array_filter($this->checklist_items));
}
return collect(preg_split('/\r\n|\r|\n/', (string) $this->deliverables_checklist))
->map(fn (string $item): string => trim($item, " \t\n\r\0\x0B-[]"))
->filter()
->values()
->all();
}
public function checklistCompleted(): array
{
return is_array($this->checklist_completed) ? $this->checklist_completed : [];
}
public function checklistProgress(): array
{
$items = $this->checklistItems();
$completed = $this->checklistCompleted();
$done = collect($items)->filter(fn (string $item): bool => (bool) ($completed[$item] ?? false))->count();
return [
'done' => $done,
'total' => count($items),
];
}
public function changeRequests(): array
{
return is_array($this->change_requests) ? array_values($this->change_requests) : [];
}
}