authorize('settings.manage'); $this->daily_capacity_hours = $capacity->hours() ?? ''; $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, DailyCapacity $capacity): 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'], 'daily_capacity_hours' => ['nullable', 'string', 'max:10'], ], [ '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'), 'daily_capacity_hours.max' => __('company.errors.daily_capacity_hours'), ]); if (! DailyCapacity::isValid($this->daily_capacity_hours)) { $this->addError('daily_capacity_hours', __('company.errors.daily_capacity_hours')); return; } try { $store->save(new CompanyDetails($this->name, $this->business_id, $this->address, $this->phone, $this->email, $this->menu_name)); $capacity->save($this->daily_capacity_hours); } catch (InvalidDailyCapacity) { $this->addError('daily_capacity_hours', __('company.errors.daily_capacity_hours')); return; } 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->daily_capacity_hours = $capacity->hours() ?? ''; $this->statusMessage = __('company.saved'); } public function render(): mixed { return $this->view()->title(__('company.title')); } }; ?>
{{ __('company.title') }}

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

{{ $statusMessage }}

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