1. Go to this page and download the library: Download panakour/filament-flat-page library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
panakour / filament-flat-page example snippets
return [
'locales' => ['en', 'fr', 'el'],
];
namespace App\Filament\Pages;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Panakour\FilamentFlatPage\Pages\FlatPage;
class Settings extends FlatPage
{
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';
protected static ?string $navigationGroup = 'Settings';
protected static ?string $title = 'Settings';
public function getSubheading(): ?string
{
return __('Manage your website settings');
}
public function getFileName(): string
{
return 'settings.json';
}
protected function getTranslatableFields(): array
{
return ['site_name', 'site_description', 'contact_address', 'contact_form_title', 'contact_form_content'];
}
protected function getFlatFilePageForm(): array
{
return [
Tabs::make('Settings')
->tabs([
Tabs\Tab::make('General')
->icon('heroicon-o-computer-desktop')
->schema([
Section::make('App Settings')
->icon('heroicon-o-computer-desktop')
->schema([
TextInput::make('site_name')
->ress')
->hint('Translatable field.')
->hintIcon('heroicon-o-language')
->label('Address')
->rows(3),
]),
Section::make('Contact Form')
->schema([
TextInput::make('contact_form_title')
->hint('Translatable field.')
->hintIcon('heroicon-o-language')
->label('Contact Form Title'),
Textarea::make('contact_form_content')
->hint('Translatable field.')
->hintIcon('heroicon-o-language')
->label('Contact Form Content')
->rows(3),
]),
]),
Tabs\Tab::make('Social Networks')
->icon('heroicon-o-heart')
->schema([
Section::make('Social Media Links')
->icon('heroicon-o-heart')
->schema([
TextInput::make('facebook')
->url()
->label('Facebook URL'),
TextInput::make('twitter')
->url()
->label('Twitter URL'),
TextInput::make('instagram')
->url()
->label('Instagram URL'),
TextInput::make('linkedin')
->url()
->label('LinkedIn URL'),
]),
]),
])
->columnSpan('full'),
];
}
}
use \Panakour\FilamentFlatPage\Facades\FilamentFlatPage;
// Get a non-translatable field
$contactEmail = FilamentFlatPage::get('settings.json', 'contact_email');
// Get a translatable field (uses current locale)
$siteName = FilamentFlatPage::get('settings.json', 'site_name');
// Get a translatable field in a specific locale
$siteNameGreek = FilamentFlatPage::get('settings.json', 'site_name', 'el');
// Get all
$allSettings = FilamentFlatPage::all('settings.json');