PHP code example of ngankt2 / filament-db-config-encrypt
1. Go to this page and download the library: Download ngankt2/filament-db-config-encrypt 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/ */
ngankt2 / filament-db-config-encrypt example snippets
return [
'table_name' => 'db_config', // The database table to store settings
'encrypt' => true, // Enable encryption for stored settings
'cache' => [
'prefix' => 'db-config', // Cache key prefix
'ttl' => 60, // Cache TTL in minutes (0 for no expiration)
],
];
namespace App\Filament\Admin\Clusters\SettingsCluster\Pages;
use Ngankt2\DbConfig\AbstractPageSettings;
use Filament\Forms\Components;
class GeneralSettings extends AbstractPageSettings
{
protected static ?string $title = 'General Settings';
protected static ?string $cluster = \App\Filament\Admin\Clusters\SettingsCluster::class;
protected function settingName(): string
{
return 'general';
}
public function getDefaultData(): array
{
return [
'site_name' => 'My Application',
'site_description' => 'A description of my application',
];
}
public function form(Form $form): Form
{
return $form
->schema([
Components\TextInput::make('site_name')
->label('Site Name')
->
// In PHP code
$value = db_config('general', [
'site_name' => 'My Application',
'site_description' => 'A description of my application',
]);
$value = \Ngankt2\DbConfig\DbConfig::getWithoutCache('general', [
'site_name' => 'My Application',
'site_description' => 'A description of my application',
]);
protected function getMerge(): bool
{
return false; // Override existing values instead of merging
}
protected function groupName(): string
{
return 'custom-group';
}