Summary of completed work: - Complete buyer portal (browse, cart, checkout, orders, invoices) - Complete seller portal (orders, manifests, fleet, picking) - Business onboarding wizards (buyer 4-step, seller 5-step) - Email verification and registration flows - Notification system for buyers and sellers - Payment term surcharges and pickup/delivery workflows - Filament admin resources (Business, Brand, Product, Order, Invoice, User) - 51 migrations executed successfully Renamed Company -> Business throughout codebase for consistency. Unified authentication flows with password reset. Added audit trail and telescope for debugging. Next: Week 4 Data Migration (Days 22-28) - Product migration (883 products from cannabrands_crm) - Company migration (81 buyer companies) - User migration (preserve password hashes) - Order history migration
71 lines
2.4 KiB
PHP
71 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
use Illuminate\Validation\Rules\Password;
|
|
use Illuminate\Validation\ValidationException;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\User;
|
|
use App\Notifications\CompleteBusinessProfileNotification;
|
|
use Illuminate\Auth\Events\Registered;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Validation\Rules;
|
|
use Illuminate\View\View;
|
|
|
|
class BuyerRegisteredUserController extends Controller
|
|
{
|
|
/**
|
|
* Display the buyer registration view.
|
|
*/
|
|
public function create(): View
|
|
{
|
|
return view('buyer.auth.register');
|
|
}
|
|
|
|
/**
|
|
* Handle buyer registration request.
|
|
*
|
|
* @throws ValidationException
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$request->validate([
|
|
'first_name' => ['required', 'string', 'max:255'],
|
|
'last_name' => ['required', 'string', 'max:255'],
|
|
'phone' => ['required', 'string', 'max:15'],
|
|
'position' => ['required', 'string', 'max:255'],
|
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
|
'password' => ['required', 'confirmed', Password::defaults()],
|
|
'business_name' => ['required', 'string', 'max:255'],
|
|
'market' => ['required', 'string', 'max:255'],
|
|
'terms' => ['required', 'accepted'],
|
|
]);
|
|
|
|
// Create buyer user record
|
|
$user = User::create([
|
|
'first_name' => $request->first_name,
|
|
'last_name' => $request->last_name,
|
|
'email' => $request->email,
|
|
'password' => Hash::make($request->password),
|
|
'phone' => $request->phone,
|
|
'position' => $request->position,
|
|
'user_type' => 'buyer', // Set as buyer
|
|
'approval_status' => 'approved', // Buyers get instant approval
|
|
'approved_at' => now(),
|
|
// Store temporary business info until business setup is completed
|
|
'temp_business_name' => $request->business_name,
|
|
'temp_market' => $request->market,
|
|
]);
|
|
|
|
event(new Registered($user));
|
|
|
|
// Auto-login buyers (they don't need approval workflow)
|
|
Auth::login($user);
|
|
|
|
return redirect()->route('buyer.dashboard')->with('success', 'Welcome to Cannabrands! Start browsing products from verified brands.');
|
|
}
|
|
}
|