Phase 8 and 9 marketplace matching

This commit is contained in:
Codex
2026-07-10 14:27:51 -05:00
parent 5009269907
commit 24f73084fa
21 changed files with 778 additions and 50 deletions
+43 -2
View File
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\JobPost;
use App\Models\TaxonomyTerm;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -11,7 +12,8 @@ class JobPostController extends Controller
{
public function index(Request $request): View
{
$jobs = JobPost::with('buyer.buyerProfile', 'attachments', 'ratings.user');
$jobs = JobPost::with('buyer.buyerProfile', 'workCategory', 'workSpecialty', 'attachments', 'ratings.user')
->withCount('quotes');
if ($search = $request->string('q')->toString()) {
$jobs->where(fn ($query) => $query
@@ -26,8 +28,35 @@ class JobPostController extends Controller
$jobs->where('status', $status);
}
if ($category = $request->integer('work_category_id')) {
$jobs->where('work_category_id', $category);
}
if ($level = $request->integer('technician_level')) {
$jobs->where('required_technician_level', '<=', $level);
}
if ($scope = $request->string('scope_clarity')->toString()) {
$jobs->where('scope_clarity_status', $scope);
}
if ($request->boolean('support_certified')) {
$jobs->where('contact_certified', true);
}
if ($request->boolean('remote_only')) {
$jobs->where(fn ($query) => $query->where('remote_eligible', true)->orWhere('work_mode', 'remote'));
}
if ($request->boolean('hide_risky')) {
$jobs->where(fn ($query) => $query->whereNull('risk_flags')->orWhereJsonLength('risk_flags', 0));
}
return view('jobs.index', [
'jobs' => $jobs->latest()->paginate(20)->withQueryString(),
'categories' => TaxonomyTerm::where('type', 'work_category')->where('is_active', true)->orderBy('sort_order')->orderBy('name')->get(),
'technicianLevels' => config('technician-levels'),
'filters' => $request->only(['q', 'status', 'work_category_id', 'technician_level', 'scope_clarity', 'support_certified', 'remote_only', 'hide_risky']),
]);
}
@@ -35,7 +64,11 @@ class JobPostController extends Controller
{
abort_unless($request->user()->hasRole('buyer'), 403);
return view('jobs.create');
return view('jobs.create', [
'categories' => TaxonomyTerm::where('type', 'work_category')->where('is_active', true)->orderBy('sort_order')->orderBy('name')->get(),
'specialties' => TaxonomyTerm::where('type', 'work_specialty')->where('is_active', true)->orderBy('sort_order')->orderBy('name')->get(),
'technicianLevels' => config('technician-levels'),
]);
}
public function store(Request $request): RedirectResponse
@@ -45,6 +78,12 @@ class JobPostController extends Controller
$data = $request->validate([
'title' => ['required', 'string', 'max:255'],
'service_category' => ['nullable', 'string', 'max:255'],
'work_category_id' => ['nullable', 'integer', 'exists:taxonomy_terms,id'],
'work_specialty_id' => ['nullable', 'integer', 'exists:taxonomy_terms,id'],
'required_technician_level' => ['required', 'integer', 'min:1', 'max:5'],
'work_mode' => ['required', 'string', 'in:onsite,remote,hybrid'],
'pay_type' => ['nullable', 'string', 'in:fixed,hourly,blended,not_listed'],
'posted_terms_summary' => ['nullable', 'string', 'max:255'],
'location' => ['required', 'string', 'max:255'],
'starts_at' => ['nullable', 'date'],
'time_window' => ['nullable', 'string', 'max:255'],
@@ -110,6 +149,8 @@ class JobPostController extends Controller
return view('jobs.show', [
'job' => $job->load(
'buyer.buyerProfile',
'workCategory',
'workSpecialty',
'quotes.provider.providerProfile',
'quotes.revisions.user',
'workOrder',
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\ProviderProfile;
use App\Models\TaxonomyTerm;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -11,7 +12,7 @@ class ProviderProfileController extends Controller
{
public function index(Request $request): View
{
$profiles = ProviderProfile::with('user', 'externalImports', 'attachments', 'ratings.user')
$profiles = ProviderProfile::with('user', 'externalImports', 'taxonomyTerms', 'attachments', 'ratings.user')
->withAvg(['ratings as average_stars' => fn ($query) => $query->whereNotNull('stars')], 'stars')
->withCount('ratings');
@@ -32,6 +33,14 @@ class ProviderProfileController extends Controller
$profiles->where('skills', 'like', "%{$skill}%");
}
if ($level = $request->integer('technician_level')) {
$profiles->where('max_technician_level', '>=', $level);
}
if ($tag = $request->integer('taxonomy_term_id')) {
$profiles->whereHas('taxonomyTerms', fn ($query) => $query->whereKey($tag));
}
if ($insurance = $request->string('insurance')->toString()) {
$profiles->where('insurance_status', 'like', "%{$insurance}%");
}
@@ -48,7 +57,14 @@ class ProviderProfileController extends Controller
return view('providers.index', [
'profiles' => $profiles->paginate(20)->withQueryString(),
'filters' => $request->only(['q', 'service_area', 'skill', 'insurance', 'public_contact', 'sort']),
'filters' => $request->only(['q', 'service_area', 'skill', 'technician_level', 'taxonomy_term_id', 'insurance', 'public_contact', 'sort']),
'technicianLevels' => config('technician-levels'),
'taxonomyTerms' => TaxonomyTerm::whereIn('type', ['work_category', 'work_specialty', 'skill', 'tool', 'certification'])
->where('is_active', true)
->orderBy('type')
->orderBy('sort_order')
->orderBy('name')
->get(),
]);
}
@@ -57,7 +73,14 @@ class ProviderProfileController extends Controller
abort_unless($request->user()->hasRole('provider'), 403);
return view('providers.edit', [
'profile' => $request->user()->providerProfile?->load('attachments', 'externalImports.attachments'),
'profile' => $request->user()->providerProfile?->load('attachments', 'externalImports.attachments', 'taxonomyTerms'),
'technicianLevels' => config('technician-levels'),
'taxonomyTerms' => TaxonomyTerm::whereIn('type', ['work_category', 'work_specialty', 'skill', 'tool', 'certification'])
->where('is_active', true)
->orderBy('type')
->orderBy('sort_order')
->orderBy('name')
->get(),
]);
}
@@ -70,7 +93,10 @@ class ProviderProfileController extends Controller
'headline' => ['nullable', 'string', 'max:255'],
'bio' => ['nullable', 'string'],
'service_area' => ['nullable', 'string', 'max:255'],
'max_technician_level' => ['required', 'integer', 'min:1', 'max:5'],
'skills' => ['nullable', 'string'],
'taxonomy_terms' => ['nullable', 'array'],
'taxonomy_terms.*' => ['integer', 'exists:taxonomy_terms,id'],
'services_text' => ['nullable', 'string'],
'tools' => ['nullable', 'string'],
'tool_inventory_text' => ['nullable', 'string'],
@@ -97,18 +123,23 @@ class ProviderProfileController extends Controller
]);
unset($data['services_text'], $data['tool_inventory_text'], $data['certification_records_text']);
$request->user()->providerProfile()->updateOrCreate(
$profile = $request->user()->providerProfile()->updateOrCreate(
['user_id' => $request->user()->id],
$data
);
$sync = collect($data['taxonomy_terms'] ?? [])
->mapWithKeys(fn ($termId): array => [(int) $termId => ['evidence_source' => 'self_declared']])
->all();
$profile->taxonomyTerms()->sync($sync);
return redirect()->route('providers.edit')->with('status', 'Provider profile saved.');
}
public function show(ProviderProfile $provider): View
{
return view('providers.show', [
'profile' => $provider->load('user', 'externalImports.attachments', 'attachments', 'ratings.user'),
'profile' => $provider->load('user', 'externalImports.attachments', 'taxonomyTerms', 'attachments', 'ratings.user'),
]);
}