Settings
The Settings page
The core adds a Settings page at /admin/settings, for super-admins and admins, with what every site has:
| Section | Fields | Read as |
|---|---|---|
| Site | Name and description, one per site language; home page; share image | site.name, site.description, site.home_page, site.share_image |
| Search engines | Title format; a switch that asks search engines not to list the site | site.seo.title_format, site.seo.noindex |
| Contact | Email, phone, address | site.contact.email, site.contact.phone, site.contact.address |
| Social profiles | Facebook, Instagram, LinkedIn, X, YouTube, TikTok | site.social.instagram, ... |
The site name is also the name shown in the admin panel. Until one is saved, the panel shows APP_NAME.
Reading a setting
Read the settings in site code through Melasistema\MelaCms\Settings. Never hard-code them in views:
use Melasistema\MelaCms\Models\Media;
use Melasistema\MelaCms\Settings;
$settings = app(Settings::class);
$settings->get('site.contact.email'); // 'info@example.com', or null
$settings->get('site.contact.phone', '-'); // with a default
$settings->translated('site.name', config('app.name')); // in the language of the request
Media::find($settings->get('site.share_image')); // a file of the media library, or null
array_filter($settings->get('site.social', [])); // ['instagram' => 'https://...'], only the ones filled intranslated() is for a value that has one entry per language. An empty translation falls back to the default language of the site, then to the default given.
All settings are stored in the mela_settings table and read with one query per request.
Version and what's new
Below the form, the page shows the MelaCMS version of the site and what that version brought, read from the core's changelog.
On a local site (APP_ENV=local) a Check for a new version button asks Composer for the newest release. When there is one, the page shows it with the command that installs it, php artisan mela:update. The update itself always runs in the terminal, never from the panel. See Updating the core.
Settings of your own
Extend the page, add fields, and name your class under pages in the config. Every field is saved under site at its own name:
namespace App\Filament\Pages;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Melasistema\MelaCms\Filament\Pages\ManageSettings;
class Settings extends ManageSettings
{
public static function formComponents(): array
{
return [
...parent::formComponents(),
Section::make('Booking')->schema([
TextInput::make('booking.url')->url(), // read as site.booking.url
]),
];
}
}// config/mela-cms.php
'pages' => [
'settings' => App\Filament\Pages\Settings::class,
],WARNING
Name the class in the config. A class in app/Filament/Pages without that entry is discovered as a second page, so the panel shows two settings pages.
Wrap a field in Translations::make() to have it per language. Override socialNetworks() to change the list of profiles. Set 'settings' => null to remove the page.