Search by

webx-ui / module-settings

Ahabzig

Site settings for the WebX UI admin panel: a screen described as JSON, patched by the project, saved by description.

Package info

github.com/webx-ui/module-settings

Homepage

Issues

pkg:composer/webx-ui/module-settings

Statistics

Installs: 795

Dependents: 2

Suggesters: 0

Stars: 0


README

Site settings as a section of the WebX UI admin panel. The screen is a JSON tree the package ships; the project lays its own tabs and fields over it with a patch, and saving goes by the same description — a key the tree does not name is not written.

Requirements

  • PHP 8.4+, Laravel 13
  • webx-ui/module-admin, webx-ui/module-auth (the panel and the sign-in), webx-ui/mcp

Install

composer require webx-ui/module-settings
php artisan migrate

The section appears once the front end lists it too: settings() from @webx-ui/module-settings in createAdmin({ modules: [...] }). Permissions: settings.view, settings.manage.

The screen

settings.index, two tabs out of the box:

id type name
tabs wx-tabs
general wx-tab
general-card wx-card
project-name wx-input general.project-name
branding wx-tab
branding-card wx-card
logo wx-media branding.logo
mark wx-media branding.mark

Those three are what the panel wears. PanelBranding answers WebxUi\Admin\Contracts\BrandingSource with them, so they reach the frame in the manifest: the name in the corner (and the logo's alt), the logo for the open sidebar, the square mark for the 56 px rail. A name left empty falls back to WEBX_ADMIN_TITLE; a picture this package cannot turn into an address — module-media is what resolves one, and it is not required — is no picture, and the corner keeps its name.

Those ids are the public contract: a project addresses them from its patch. Add what the site needs from a service provider that boots after this one — the application's own does:

use WebxUi\Admin\Facades\Screens;

Screens::extend('settings.index', resource_path('screens/settings.json'));
[
  {
    "op": "add",
    "target": "tabs",
    "node": {
      "id": "seo",
      "type": "wx-tab",
      "label": "SEO",
      "children": [
        {
          "id": "seo-card",
          "type": "wx-card",
          "children": [
            {
              "id": "robots",
              "type": "wx-textarea",
              "name": "seo.robots-txt",
              "label": "robots.txt"
            }
          ]
        }
      ]
    }
  }
]

A field added by a patch is a field the server accepts: validated with the rules its type declares, per language when localized, stored under its name.

Reading a setting

settings('general.project-name');          // the current language, with the site's fallbacks
settings('seo.robots-txt', 'User-agent: *');
settings()->all();                          // everything the screen describes, resolved

Values are cached whole and the cache is dropped on save; WebxUi\Settings\Events\SettingsSaved carries the keys that changed.

MCP

settings_list, settings_get, settings_set (mutating, honours dry_run) — the keys and the rules come from the screen, so an agent can change exactly what an administrator can. value: null (or the string "null") clears a setting of any type, every language at once; {"de": null} empties one language. A cleared key has no row, so settings('key', $default) returns the default.

Languages

en, ru, uk, de, pl, fr, es, it, pt, tr. Only English, Russian and Ukrainian have been read by a speaker.

Licence

MIT.