exists) { $this->organization = $organization; $this->name = $organization->name; $this->org_type = $organization->org_type ?? 'client'; $this->status = $organization->status; $this->description = $organization->description ?? ''; $this->allowed_ip_ranges = implode("\n", $organization->allowed_ip_ranges ?? []); } } public function save(): void { $validated = $this->validate([ 'name' => 'required|string|max:255', 'org_type' => 'required|in:client,internal,vendor', 'status' => 'required|in:active,inactive', 'description' => 'nullable|string', 'logo' => 'nullable|image|max:2048', ]); unset($validated['logo']); $ranges = collect(preg_split('/\r?\n/', $this->allowed_ip_ranges)) ->map(fn ($line) => trim($line)) ->filter() ->values() ->all(); $validated['allowed_ip_ranges'] = $ranges ?: null; if ($this->organization?->exists) { $this->organization->update($validated); } else { $validated['slug'] = Str::slug($this->name).'-'.Str::random(6); $this->organization = Organization::create($validated); } if ($this->logo) { if ($this->organization->logo_path) { Storage::disk('public')->delete($this->organization->logo_path); } $path = $this->logo->store("organizations/{$this->organization->id}", 'public'); $this->organization->update(['logo_path' => $path]); } session()->flash('status', "Organisation « {$this->organization->name} » enregistrée."); $this->redirectRoute('organizations.index', navigate: true); } }; ?>

{{ $organization?->exists ? 'Modifier l\'organisation' : 'Nouvelle organisation' }}

@if ($organization?->exists) @endif
Logo

L'image pourra être recadrée avant l'envoi.

@error('logo')

{{ $message }}

@enderror

Recadrer le logo

Zoom
@error('name')

{{ $message }}

@enderror

Laisser vide pour autoriser l'accès depuis n'importe quelle IP.

Annuler
@once @endonce