Phase 8 and 9 marketplace matching
This commit is contained in:
+26
-1
@@ -11,7 +11,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'buyer_id', 'title', 'status', 'service_category', 'location', 'starts_at',
|
||||
'time_window', 'schedule_type', 'remote_eligible', 'scope', 'primary_objective',
|
||||
'work_category_id', 'work_specialty_id', 'required_technician_level', 'work_mode',
|
||||
'pay_type', 'posted_terms_summary', 'time_window', 'schedule_type', 'remote_eligible', 'scope', 'primary_objective',
|
||||
'included_work', 'excluded_work', 'maximum_onsite_expectations', 'expected_duration',
|
||||
'required_skills', 'required_tools', 'required_certifications', 'required_safety_gear',
|
||||
'deliverables', 'closeout_conditions', 'buyer_provided_equipment',
|
||||
@@ -38,6 +39,7 @@ class JobPost extends Model
|
||||
{
|
||||
return [
|
||||
'starts_at' => 'datetime',
|
||||
'required_technician_level' => 'integer',
|
||||
'remote_eligible' => 'boolean',
|
||||
'risk_flags' => 'array',
|
||||
'contact_certified' => 'boolean',
|
||||
@@ -50,6 +52,16 @@ class JobPost extends Model
|
||||
return $this->belongsTo(User::class, 'buyer_id');
|
||||
}
|
||||
|
||||
public function workCategory(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TaxonomyTerm::class, 'work_category_id');
|
||||
}
|
||||
|
||||
public function workSpecialty(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TaxonomyTerm::class, 'work_specialty_id');
|
||||
}
|
||||
|
||||
public function quotes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Quote::class);
|
||||
@@ -95,6 +107,10 @@ class JobPost extends Model
|
||||
'parking_access_notes' => $this->parking_access_notes,
|
||||
'onsite_restrictions' => $this->onsite_restrictions,
|
||||
'supplemental_instructions' => $this->supplemental_instructions,
|
||||
'required_technician_level' => $this->required_technician_level,
|
||||
'technician_level' => $this->technicianLevel()['name'],
|
||||
'work_category' => $this->workCategory?->name,
|
||||
'work_specialty' => $this->workSpecialty?->name,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -152,6 +168,10 @@ class JobPost extends Model
|
||||
$flags[] = 'compressed_schedule';
|
||||
}
|
||||
|
||||
if ((int) $this->required_technician_level <= 1 && ($this->required_certifications || str_contains(strtolower((string) $this->primary_objective.' '.$this->included_work), 'troubleshoot'))) {
|
||||
$flags[] = 'level_scope_mismatch';
|
||||
}
|
||||
|
||||
return array_values(array_unique($flags));
|
||||
}
|
||||
|
||||
@@ -173,4 +193,9 @@ class JobPost extends Model
|
||||
|
||||
return 'clear';
|
||||
}
|
||||
|
||||
public function technicianLevel(): array
|
||||
{
|
||||
return config('technician-levels')[(int) $this->required_technician_level] ?? config('technician-levels')[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'user_id', 'business_name', 'headline', 'bio', 'service_area', 'skills',
|
||||
'services', 'tools', 'tool_inventory', 'certifications', 'certification_records',
|
||||
'max_technician_level', 'services', 'tools', 'tool_inventory', 'certifications', 'certification_records',
|
||||
'insurance_status', 'rate_card', 'travel_policy', 'availability_notes',
|
||||
'website_url', 'phone', 'public_contact', 'profile_visibility', 'private_notes',
|
||||
])]
|
||||
@@ -24,6 +25,7 @@ class ProviderProfile extends Model
|
||||
'certification_records' => 'array',
|
||||
'profile_visibility' => 'array',
|
||||
'public_contact' => 'boolean',
|
||||
'max_technician_level' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -47,6 +49,18 @@ class ProviderProfile extends Model
|
||||
return $this->morphMany(Rating::class, 'rateable');
|
||||
}
|
||||
|
||||
public function taxonomyTerms(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TaxonomyTerm::class)
|
||||
->withPivot('evidence_source')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function technicianLevel(): array
|
||||
{
|
||||
return config('technician-levels')[(int) $this->max_technician_level] ?? config('technician-levels')[1];
|
||||
}
|
||||
|
||||
public function visible(string $field): bool
|
||||
{
|
||||
$visibility = $this->profile_visibility ?? [];
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable(['parent_id', 'type', 'name', 'slug', 'description', 'sort_order', 'is_active'])]
|
||||
class TaxonomyTerm extends Model
|
||||
{
|
||||
public const TYPES = [
|
||||
'work_category',
|
||||
'work_specialty',
|
||||
'skill',
|
||||
'tool',
|
||||
'certification',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function providerProfiles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(ProviderProfile::class)
|
||||
->withPivot('evidence_source')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -198,4 +198,11 @@ class WorkOrder extends Model
|
||||
->whereIn('event_type', ['contact_failed', 'support_unavailable', 'site_contact_unavailable'])
|
||||
->count();
|
||||
}
|
||||
|
||||
public function technicianLevel(): array
|
||||
{
|
||||
$level = $this->scopeSnapshotValue('required_technician_level') ?? $this->jobPost?->required_technician_level ?? 1;
|
||||
|
||||
return config('technician-levels')[(int) $level] ?? config('technician-levels')[1];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user