62220186af
- New ExternalImportSource and ExternalWorkHistoryEntry models, controller and migrations - Screening fields on external profile imports - Admin and provider profile views, routes and workflow tests updated - Phase 1 validation, route inventory, gap report template and roadmap docs - Add the Google Sheets work-order parser tool (tools/google-sheets-wo-parser)
89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
#[Fillable([
|
|
'provider_profile_id', 'platform', 'external_id', 'profile_url', 'status',
|
|
'visibility', 'verification_status', 'verified_by_id', 'verified_at',
|
|
'background_check_status', 'background_check_date', 'drug_test_status', 'drug_test_date',
|
|
'rating', 'review_count', 'completed_jobs', 'work_categories', 'endorsements',
|
|
'operational_metrics', 'metrics', 'review_snapshots', 'selected_reviews',
|
|
'notes', 'imported_at',
|
|
])]
|
|
class ExternalProfileImport extends Model
|
|
{
|
|
public const VISIBILITIES = [
|
|
'private' => 'Private only',
|
|
'summary' => 'Public summary only',
|
|
'selected_reviews' => 'Public selected reviews',
|
|
'proof_public' => 'Public proof attachments',
|
|
];
|
|
|
|
public const VERIFICATION_STATUSES = [
|
|
'unverified' => 'Unverified imported history',
|
|
'provider_attested' => 'Provider attested',
|
|
'admin_verified' => 'Admin verified',
|
|
'needs_more_proof' => 'Needs more proof',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'work_categories' => 'array',
|
|
'endorsements' => 'array',
|
|
'operational_metrics' => 'array',
|
|
'metrics' => 'array',
|
|
'review_snapshots' => 'array',
|
|
'selected_reviews' => 'array',
|
|
'verified_at' => 'datetime',
|
|
'imported_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function providerProfile(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProviderProfile::class);
|
|
}
|
|
|
|
public function verifiedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'verified_by_id');
|
|
}
|
|
|
|
public function attachments(): MorphMany
|
|
{
|
|
return $this->morphMany(Attachment::class, 'attachable');
|
|
}
|
|
|
|
public function sources(): HasMany
|
|
{
|
|
return $this->hasMany(ExternalImportSource::class);
|
|
}
|
|
|
|
public function workHistoryEntries(): HasMany
|
|
{
|
|
return $this->hasMany(ExternalWorkHistoryEntry::class);
|
|
}
|
|
|
|
public function publiclyVisible(): bool
|
|
{
|
|
return $this->visibility !== 'private';
|
|
}
|
|
|
|
public function canShowSelectedReviews(): bool
|
|
{
|
|
return in_array($this->visibility, ['selected_reviews', 'proof_public'], true);
|
|
}
|
|
|
|
public function canShowProofAttachments(): bool
|
|
{
|
|
return $this->visibility === 'proof_public';
|
|
}
|
|
}
|