PHP code example of e2d2-dev / filament-fqn-settings
1. Go to this page and download the library: Download e2d2-dev/filament-fqn-settings 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/ */
e2d2-dev / filament-fqn-settings example snippets
use Betta\Filament\FqnSettings\FqnSettingsPlugin;
use Filament\Panel;
use Filament\PanelProvider;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FqnSettingsPlugin::make(),
]);
}
}
use Betta\Settings\Settings;
class SomeServiceProvider extends ServiceProvider
{
public function register(): void
{
Settings::path(
'path/to/files',
'Vendor\\Package'
);
}
}
use Betta\Filament\FqnSettings\Values\SettingSchema;
class BaseSchema extends SettingSchema
{
protected array $fqnSettings = [
SomeValue::class,
SecondValue::class,
];
}
use Betta\Filament\FqnSettings\Values\SettingSchema;
use Filament\Forms\Components\TextInput;
use App\Settings\SomeValue;
class BaseSchema extends SettingSchema
{
protected array $fqnSettings = [
SomeValue::class,
];
public function schema(): array
{
return [
TextInput::make(SomeValue::getStatePath()),
];
}
}
use Filament\Forms\Components\TextInput;
use Filament\Forms\Get;
use App\Settings\SomeValue;
use App\Settings\OtherValue;
TextInput::make(SomeValue::getStatePath()),
TextInput::make(OtherValue::getStatePath())
->visible(fn(Get $get) => $get(SomeValue::getStatePath())),
use App\Settings\SomeValue;
use Betta\Filament\FqnSettings\Enums\SchemaAs;
use Betta\Filament\FqnSettings\Values\SettingSchema;
class BaseSchema extends SettingSchema
{
protected \BackedEnum $returnAs = SchemaAs::Section;
// Rest of your schema class...
}
use Betta\Filament\FqnSettings\Values\SettingSchema;
use Illuminate\Contracts\Support\Htmlable;
use Closure;
class BaseSchema extends SettingSchema
{
public function getHeading(): string|Htmlable|Closure|null
{
return 'My Schema Heading';
}
public function getDescription(): string|Htmlable|Closure|null
{
return 'This is a description of my schema';
}
public function getIcon(): string|Htmlable|Closure|null
{
return 'heroicon-o-cog';
}
public function getIconColor(): string|array|null
{
return 'primary';
}
public function columnSpan(?int $columnSpan = 1): int
{
return $columnSpan;
}
public function columns(?int $columns = 1): int
{
return $columns;
}
}
use Filament\Forms\Components\Tabs\Tab;
use Betta\Filament\FqnSettings\Values\SettingSchema;
class BaseSchema extends SettingSchema
{
public function baseTab(Tab $tab): Tab
{
return $tab->schema([
// Components
]);
}
public function advancedTab(Tab $tab): Tab
{
return $tab->schema([
// Components
]);
}
}
use Betta\Filament\FqnSettings\Pages\SettingPage;
use App\Filament\Settings\Schemas\SomeSchema;
use App\Filament\Settings\Schemas\OneMoreSchema;
class SettingsPage extends SettingPage
{
protected array $schemas = [
SomeSchema::class,
OneMoreSchema::class,
];
}
use Betta\Filament\FqnSettings\Pages\SettingPage;
class SettingsPage extends SettingPage
{
public function mutateSaveDataUsing(array $data): array
{
// Modify $data as needed
return $data;
}
}
use Betta\Filament\FqnSettings\Pages\SettingPage;
class SettingsPage extends SettingPage
{
public function fillAdditionalData(): array
{
return [
'customData' => 'value',
'anotherCustomData' => [
'nested' => 'value',
],
];
}
}
use Betta\Filament\FqnSettings\Pages\SettingPage;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Placeholder;
class SettingsPage extends SettingPage
{
public function beforeSchema(): array
{
return [
Section::make('Before Schema Section')
->schema([
Placeholder::make('info')
->content('This appears before the schema'),
]),
];
}
public function afterSchema(): array
{
return [
Section::make('After Schema Section')
->schema([
Placeholder::make('info')
->content('This appears after the schema'),
]),
];
}
}
shell
php artisan make:setting
shell
php artisan setting:schema
shell
php artisan setting:page
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.