partner_id) { $this->redirect(route('dashboard'), navigate: true); return; } $role = $user->roles->first(); if ($role) { $this->roleIcon = $role->icon ?? 'shield-check'; $this->roleName = $role->display_name ?? $role->name; } $this->partner = Partner::with('users')->findOrFail($user->partner_id); $this->partnerType = $this->partner->type; // Vorausfüllen $this->companyName = $this->partner->company_name; $this->description = $this->partner->description ?? ''; $this->website = ''; // Definiere Schritte basierend auf Rolle $this->defineSteps(); } protected function defineSteps(): void { switch ($this->partnerType) { case 'Retailer': $this->steps = ['Stammdaten', 'Liefergebiete', 'Fertig']; $this->totalSteps = 3; break; case 'Manufacturer': $this->steps = ['Stammdaten', 'Marke anlegen', 'Fertig']; $this->totalSteps = 3; break; case 'Estate-Agent': $this->steps = ['Profil', 'Fertig']; $this->totalSteps = 2; break; default: $this->steps = ['Stammdaten', 'Fertig']; $this->totalSteps = 2; break; } } public function saveStep1(): void { $this->validate( [ 'companyName' => 'required|string|max:255', 'description' => 'nullable|string|max:1000', 'street' => 'required|string|max:255', 'zip' => 'required|string|max:10', 'city' => 'required|string|max:255', 'website' => 'nullable|url|max:255', 'logo' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:2048', ], [ 'companyName.required' => __('Bitte geben Sie einen Firmennamen ein.'), 'street.required' => __('Bitte geben Sie eine Straße ein.'), 'zip.required' => __('Bitte geben Sie eine Postleitzahl ein.'), 'city.required' => __('Bitte geben Sie eine Stadt ein.'), 'website.url' => __('Bitte geben Sie eine gültige URL ein.'), 'logo.image' => __('Das Logo muss eine Bilddatei sein.'), 'logo.mimes' => __('Das Logo muss im Format JPG, PNG oder WebP sein.'), 'logo.max' => __('Das Logo darf maximal 2 MB groß sein.'), ], ); // Speichere Logo falls hochgeladen $logoPath = null; if ($this->logo) { $logoPath = $this->logo->store('partner-logos', 'public'); } // Update Partner $this->partner->update([ 'company_name' => $this->companyName, 'description' => $this->description, 'logo_url' => $logoPath ?? $this->partner->logo_url, ]); // TODO: Adresse speichern (separates Address-Model oder JSON-Feld) $this->currentStep = 2; } public function saveStep2Retailer(): void { $this->validate( [ 'deliveryRadius' => 'required|integer|min:1|max:500', 'assemblyRadius' => 'required|integer|min:1|max:500', ], [ 'deliveryRadius.required' => __('Bitte geben Sie einen Lieferradius ein.'), 'deliveryRadius.min' => __('Der Lieferradius muss mindestens 1 km betragen.'), 'assemblyRadius.required' => __('Bitte geben Sie einen Montageradius ein.'), 'assemblyRadius.min' => __('Der Montageradius muss mindestens 1 km betragen.'), ], ); $this->partner->update([ 'delivery_radius_km' => $this->deliveryRadius, 'assembly_radius_km' => $this->assemblyRadius, ]); $this->completeSetup(); } public function saveStep2Manufacturer(): void { $this->validate( [ 'brandName' => 'required|string|max:255', 'brandDescription' => 'nullable|string|max:1000', 'brandLogo' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:2048', ], [ 'brandName.required' => __('Bitte geben Sie einen Markennamen ein.'), 'brandLogo.image' => __('Das Marken-Logo muss eine Bilddatei sein.'), 'brandLogo.mimes' => __('Das Marken-Logo muss im Format JPG, PNG oder WebP sein.'), 'brandLogo.max' => __('Das Marken-Logo darf maximal 2 MB groß sein.'), ], ); // Speichere Brand-Logo falls hochgeladen $brandLogoPath = null; if ($this->brandLogo) { $brandLogoPath = $this->brandLogo->store('brand-logos', 'public'); } // Erstelle Brand Brand::create([ 'partner_id' => $this->partner->id, 'name' => $this->brandName, 'slug' => Str::slug($this->brandName), 'description' => $this->brandDescription, 'logo_url' => $brandLogoPath, 'is_active' => true, ]); $this->completeSetup(); } protected function completeSetup(): void { $this->partner->update([ 'is_active' => true, 'setup_completed' => true, 'setup_completed_at' => now(), ]); $this->currentStep = $this->totalSteps; } public function goToDashboard(): void { $this->redirect(route('dashboard'), navigate: true); } public function logout(): void { Auth::logout(); request()->session()->invalidate(); request()->session()->regenerateToken(); $this->redirect(route('home'), navigate: true); } }; ?>