authorize('settings.manage'); $details = $store->get(); if ($details !== null) { $this->name = $details->name; $this->menu_name = $details->menuName ?? ''; $this->business_id = $details->businessId; $this->address = $details->address ?? ''; $this->phone = $details->phone ?? ''; $this->email = $details->email ?? ''; } } public function save(CompanyDetailsStore $store): void { $this->authorize('settings.manage'); $this->statusMessage = ''; $this->validate([ 'name' => ['required', 'string', 'max:255'], 'menu_name' => ['nullable', 'string', 'max:100'], 'business_id' => ['required', 'string', 'max:20'], 'address' => ['nullable', 'string', 'max:500'], 'phone' => ['nullable', 'string', 'max:50'], 'email' => ['nullable', 'string', 'max:255'], ], [ 'name.required' => __('company.errors.name'), 'name.max' => __('company.errors.name'), 'menu_name.max' => __('company.errors.menu_name'), 'business_id.required' => __('company.errors.business_id'), 'business_id.max' => __('company.errors.business_id'), 'address.max' => __('company.errors.address'), 'phone.max' => __('company.errors.phone'), 'email.max' => __('company.errors.email'), ]); try { $store->save(new CompanyDetails($this->name, $this->business_id, $this->address, $this->phone, $this->email, $this->menu_name)); } catch (CompanyNameRequired) { $this->addError('name', __('company.errors.name')); return; } catch (InvalidBusinessId) { $this->addError('business_id', __('company.errors.business_id')); return; } catch (InvalidEmailAddress) { $this->addError('email', __('company.errors.email')); return; } $this->business_id = (string) $store->get()?->businessId; $this->statusMessage = __('company.saved'); } public function render(): mixed { return $this->view()->title(__('company.title')); } }; ?>

{{ __('company.title') }}

{{ __('company.intro') }}

{{ $statusMessage }}