|null */ public ?array $data = []; public static function canAccess(): bool { return auth()->user()?->can('manage_settings') ?? false; } public function mount(): void { $this->form->fill([ 'site_name' => config('app.name'), 'support_email' => config('app.support_email'), 'support_phone' => config('app.support_phone'), 'timezone' => config('app.timezone'), 'currency' => config('app.currency'), 'back_seat_enabled' => (bool) config('booking.back_seat_enabled'), 'whole_vehicle_enabled' => (bool) config('booking.whole_vehicle_enabled'), 'front_seat_max_per_booking' => config('booking.front_seat_max_per_booking'), ]); } public function form(Schema $schema): Schema { return $schema ->components([ Form::make([ Tabs::make('Settings') ->tabs([ Tab::make('General') ->schema([ TextInput::make('site_name') ->label('Site Name') ->required() ->maxLength(255), TextInput::make('support_email') ->label('Support Email') ->email() ->maxLength(255), TextInput::make('support_phone') ->label('Support Phone') ->tel() ->maxLength(255), TextInput::make('timezone') ->label('Timezone') ->required() ->maxLength(64) ->helperText('A valid PHP timezone identifier, e.g. Asia/Yangon.'), TextInput::make('currency') ->label('Currency Code') ->required() ->maxLength(3) ->helperText('ISO 4217 currency code, e.g. MMK.'), ]) ->columns(2), Tab::make('Booking') ->schema([ Toggle::make('back_seat_enabled') ->label('Back Seat Enabled') ->helperText('Whether customers can select Back Seat at all right now.'), Toggle::make('whole_vehicle_enabled') ->label('Whole Vehicle Enabled') ->helperText('Whether customers can select Whole Vehicle at all right now.'), TextInput::make('front_seat_max_per_booking') ->label('Front Seat Max Per Booking') ->numeric() ->minValue(1) ->required() ->helperText('Max Front Seats a single booking may request.'), ]), ]), ]) ->livewireSubmitHandler('save') ->footer([ Actions::make([ Action::make('save') ->submit('save') ->keyBindings(['mod+s']), ]), ]), ]) ->statePath('data'); } public function save(EnvFileWriter $writer): void { $state = $this->form->getState(); $writer->write([ 'APP_NAME' => $state['site_name'], 'SUPPORT_EMAIL' => $state['support_email'], 'SUPPORT_PHONE' => $state['support_phone'], 'APP_TIMEZONE' => $state['timezone'], 'APP_CURRENCY' => $state['currency'], 'BOOKING_BACK_SEAT_ENABLED' => (bool) $state['back_seat_enabled'], 'BOOKING_WHOLE_VEHICLE_ENABLED' => (bool) $state['whole_vehicle_enabled'], 'BOOKING_FRONT_SEAT_MAX_PER_BOOKING' => (int) $state['front_seat_max_per_booking'], ]); Artisan::call('config:clear'); Notification::make() ->title('Settings saved') ->success() ->send(); } }