This commit is contained in:
Codex
2026-07-10 09:14:42 -05:00
parent e27fcc6c19
commit 63820994f8
55 changed files with 2195 additions and 86 deletions
@@ -0,0 +1,61 @@
<?php
namespace App\Http\Controllers;
use App\Models\BuyerProfile;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class BuyerProfileController extends Controller
{
public function index(): View
{
return view('buyers.index', [
'profiles' => BuyerProfile::with('user')->latest()->paginate(20),
]);
}
public function edit(Request $request): View
{
abort_unless($request->user()->hasRole('buyer'), 403);
return view('buyers.edit', [
'profile' => $request->user()->buyerProfile,
]);
}
public function update(Request $request): RedirectResponse
{
abort_unless($request->user()->hasRole('buyer'), 403);
$data = $request->validate([
'company_name' => ['required', 'string', 'max:255'],
'headline' => ['nullable', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'service_categories' => ['nullable', 'string'],
'hiring_regions' => ['nullable', 'string'],
'vendor_onboarding' => ['nullable', 'string'],
'payment_terms' => ['nullable', 'string'],
'website_url' => ['nullable', 'url', 'max:255'],
'contact_email' => ['nullable', 'email', 'max:255'],
'public_contact' => ['nullable', 'boolean'],
]);
$data['public_contact'] = $request->boolean('public_contact');
$request->user()->buyerProfile()->updateOrCreate(
['user_id' => $request->user()->id],
$data
);
return redirect()->route('buyers.edit')->with('status', 'Buyer profile saved.');
}
public function show(BuyerProfile $buyer): View
{
return view('buyers.show', [
'profile' => $buyer->load('user'),
]);
}
}