feat: add Website Settings, Imap Settings and Configuration Settings via inerba/filament-db-config
This commit is contained in:
163
app/Filament/Pages/ConfigurationSettings.php
Normal file
163
app/Filament/Pages/ConfigurationSettings.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Inerba\DbConfig\AbstractPageSettings;
|
||||
|
||||
class ConfigurationSettings extends AbstractPageSettings
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed> | null
|
||||
*/
|
||||
public ?array $data = [];
|
||||
|
||||
protected static ?string $title = 'Configuration Settings';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-wrench-screwdriver'; // Uncomment if you want to set a custom navigation icon
|
||||
|
||||
// protected ?string $subheading = ''; // Uncomment if you want to set a custom subheading
|
||||
|
||||
// protected static ?string $slug = 'configuration-settings'; // Uncomment if you want to set a custom slug
|
||||
|
||||
protected string $view = 'filament.pages.configuration-settings';
|
||||
|
||||
protected function settingName(): string
|
||||
{
|
||||
return 'configuration';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default values.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'enable_masking_external_link' => true,
|
||||
'enable_create_from_url' => true,
|
||||
'font_family' => [
|
||||
'head' => 'Poppins',
|
||||
'body' => 'Poppins',
|
||||
],
|
||||
'default_language' => 'en',
|
||||
'fetch_seconds' => 15,
|
||||
'email_limit' => 10,
|
||||
'fetch_messages_limit' => 15,
|
||||
'cron_password' => Str::random(20),
|
||||
'date_format' => 'd M Y h:i A',
|
||||
'custom_username_length_min' => 3,
|
||||
'custom_username_length_max' => 20,
|
||||
'random_username_length_min' => 0,
|
||||
'random_username_length_max' => 0,
|
||||
'after_last_email_delete' => 'redirect_to_homepage',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('General Configuration')
|
||||
->schema([
|
||||
Checkbox::make('enable_masking_external_link')
|
||||
->label('Enable URL Masking of External URL')
|
||||
->default(false)
|
||||
->columnSpan(1)
|
||||
->helperText('If you enable this, then we will use href.li to remove your site footprint being passed-on to external link.'),
|
||||
Checkbox::make('disable_mailbox_slug')
|
||||
->label('Disable Mailbox Slug')
|
||||
->default(false)
|
||||
->columnSpan(1)
|
||||
->helperText('If you enable this, then we will disable mailbox slug.'),
|
||||
Checkbox::make('enable_create_from_url')
|
||||
->label('Enable Mail ID Creation from URL')
|
||||
->default(true)
|
||||
->columnSpan(1)
|
||||
->helperText('If you enable this, then users will be able to create email ID from URL.'),
|
||||
Checkbox::make('enable_ad_block_detector')
|
||||
->label('Enable Ad Block Detector')
|
||||
->default(true)
|
||||
->columnSpan(1)
|
||||
->helperText('If you enable this, then we block all the users from using when that have Ad Blocker enabled.'),
|
||||
KeyValue::make('font_family')
|
||||
->label('Font Family')
|
||||
->columnSpan(2)
|
||||
->helperText('Use Google Fonts with exact name.'),
|
||||
]),
|
||||
|
||||
Select::make('default_language')->options([
|
||||
'ar' => 'Arabic',
|
||||
'de' => 'German',
|
||||
'en' => 'English',
|
||||
'fr' => 'French',
|
||||
'hi' => 'Hindi',
|
||||
'pl' => 'Polish',
|
||||
'ru' => 'Russian',
|
||||
'es' => 'Spanish',
|
||||
'vi' => 'Viet',
|
||||
'tr' => 'Turkish',
|
||||
'no' => 'Norwegian',
|
||||
'id' => 'Indonesian',
|
||||
]),
|
||||
|
||||
Section::make('Mailbox Configuration')
|
||||
->collapsed()
|
||||
->schema([
|
||||
Checkbox::make('add_mail_in_title')->label('Add Mail In Title')->default(false)->required()->helperText('If you enable this, then we will automatically add the created temp mail to the page title.'),
|
||||
Checkbox::make('disable_used_email')->label('Disable Used Email')->default(false)->required()->helperText('If you enable this, same email address cannot be created by user from different IP for one week.'),
|
||||
TextInput::make('fetch_seconds')->label('Fetch Seconds')->numeric()->required(),
|
||||
TextInput::make('email_limit')->label('Email Limit')->numeric()->required()->helperText('Limit on number of email ids that can be created per IP address in 24 hours. Recommended - 5.'),
|
||||
TextInput::make('fetch_messages_limit')->label('Fetch Messages Limit')->numeric()->required()->helperText('Limit of messages retrieved at a time. Keep it to as low as possible. Default - 15.'),
|
||||
TextInput::make('cron_password')->label('Cron Password')->required(),
|
||||
TextInput::make('date_format')->label('Date Format')->placeholder('d M Y h:i A')->required(),
|
||||
Section::make('Custom Username Lengths')
|
||||
->description('Username length for custom input')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('custom_username_length_min')->numeric()->minValue(3)->label('Custom Username Min Length')->required(),
|
||||
TextInput::make('custom_username_length_max')->numeric()->minValue(3)->label('Custom Username Max Length')->required(),
|
||||
]),
|
||||
Section::make('Random Username Lengths')
|
||||
->description('Username length for random username')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('random_username_length_min')->numeric()->minValue(0)->label('Random Username Min Length')->required(),
|
||||
TextInput::make('random_username_length_max')->numeric()->minValue(0)->label('Random Username Max Length')->required(),
|
||||
]),
|
||||
Select::make('after_last_email_delete')->options([
|
||||
'redirect_to_homepage' => 'Redirect to homepage',
|
||||
'create_new_email' => 'Create new Email',
|
||||
])->required(),
|
||||
]),
|
||||
Section::make('Forbidden Username & Blocked Domains')
|
||||
->columns(2)
|
||||
->collapsed()
|
||||
->schema([
|
||||
Repeater::make('forbidden_ids')
|
||||
->statePath('forbidden_ids')
|
||||
->columnSpan(1)
|
||||
->schema([
|
||||
TextInput::make('forbidden_id')->label('Forbidden IDs')->required()->maxLength(30),
|
||||
]),
|
||||
Repeater::make('blocked_domains')
|
||||
->statePath('blocked_domains')
|
||||
->columnSpan(1)
|
||||
->schema([
|
||||
TextInput::make('blocked_domain')->label('Blocked Domain')->required()->maxLength(30),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
}
|
||||
95
app/Filament/Pages/ImapSettings.php
Normal file
95
app/Filament/Pages/ImapSettings.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Inerba\DbConfig\AbstractPageSettings;
|
||||
|
||||
class ImapSettings extends AbstractPageSettings
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed> | null
|
||||
*/
|
||||
public ?array $data = [];
|
||||
|
||||
protected static ?string $title = 'Imap Settings';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedEnvelope; // Uncomment if you want to set a custom navigation icon
|
||||
|
||||
// protected ?string $subheading = ''; // Uncomment if you want to set a custom subheading
|
||||
|
||||
// protected static ?string $slug = 'imap-settings'; // Uncomment if you want to set a custom slug
|
||||
|
||||
protected string $view = 'filament.pages.imap-settings';
|
||||
|
||||
protected function settingName(): string
|
||||
{
|
||||
return 'imap';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default values.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'public.default_account' => 'default',
|
||||
'public.protocol' => 'imap',
|
||||
'premium.default_email' => 'default',
|
||||
'premium.protocol' => 'imap',
|
||||
];
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Public Mailbox Imap')
|
||||
->description('Enter your imap server')
|
||||
->collapsible()
|
||||
->schema([
|
||||
TextInput::make('public.host')->label('Hostname')->required(),
|
||||
TextInput::make('public.port')->label('Port')->required(),
|
||||
Select::make('public.encryption')->options([
|
||||
'none' => 'None',
|
||||
'ssl' => 'SSL',
|
||||
'tls' => 'TLS',
|
||||
]),
|
||||
Checkbox::make('public.validate_cert')->label('Validate Encryption Certificate')->default(false),
|
||||
TextInput::make('public.username')->label('Username')->required(),
|
||||
TextInput::make('public.password')->label('Password')->required(),
|
||||
TextInput::make('public.default_account')->label('Default Account')->placeholder('default'),
|
||||
TextInput::make('public.protocol')->label('Protocol')->placeholder('imap'),
|
||||
Checkbox::make('public.cc_check')->label('Check CC Field')->default(false)->helperText('If enabled, we will check the CC field as well while fetching mails.'),
|
||||
]),
|
||||
|
||||
Section::make('Premium Mailbox Imap')
|
||||
->description('Enter your imap server')
|
||||
->collapsed()
|
||||
->schema([
|
||||
TextInput::make('premium.host')->label('Hostname')->required(),
|
||||
TextInput::make('premium.port')->label('Port')->required(),
|
||||
Select::make('premium.encryption')->options([
|
||||
'none' => 'None',
|
||||
'ssl' => 'SSL',
|
||||
'tls' => 'TLS',
|
||||
]),
|
||||
Checkbox::make('premium.validate_cert')->label('Validate Encryption Certificate')->default(false),
|
||||
TextInput::make('premium.username')->label('Username')->required(),
|
||||
TextInput::make('premium.password')->label('Password')->required(),
|
||||
TextInput::make('premium.default_account')->label('Default Account')->placeholder('default'),
|
||||
TextInput::make('premium.protocol')->label('Protocol')->placeholder('imap'),
|
||||
Checkbox::make('premium.cc_check')->label('Check CC Field')->default(false)->helperText('If enabled, we will check the CC field as well while fetching mails.'),
|
||||
]),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
}
|
||||
108
app/Filament/Pages/WebsiteSettings.php
Normal file
108
app/Filament/Pages/WebsiteSettings.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Inerba\DbConfig\AbstractPageSettings;
|
||||
|
||||
class WebsiteSettings extends AbstractPageSettings
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed> | null
|
||||
*/
|
||||
public ?array $data = [];
|
||||
|
||||
protected static ?string $title = 'Website Settings';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCog6Tooth; // Uncomment if you want to set a custom navigation icon
|
||||
|
||||
// protected ?string $subheading = ''; // Uncomment if you want to set a custom subheading
|
||||
|
||||
// protected static ?string $slug = 'website-settings'; // Uncomment if you want to set a custom slug
|
||||
|
||||
protected string $view = 'filament.pages.website-settings';
|
||||
|
||||
protected function settingName(): string
|
||||
{
|
||||
return 'website';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default values.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Website Information')
|
||||
->description('Change Basic Website Information')
|
||||
->collapsible()
|
||||
->schema([
|
||||
TextInput::make('app_name')->label('Website Name')->required(),
|
||||
TextInput::make('app_version')->label('Website Version')->required(),
|
||||
TextInput::make('app_base_url')->label('Base URL')->required(),
|
||||
TextInput::make('app_admin')->label('Website Admin')->email()->required(),
|
||||
TextInput::make('app_contact')->label('Contact Email')->email()->required(),
|
||||
]),
|
||||
Section::make('Custom Codes')
|
||||
->description('Add custom codes to header and footer')
|
||||
->collapsed()
|
||||
->columns(2)
|
||||
->schema([
|
||||
Textarea::make('app_header')->label('Custom Header')->rows(6)->columnSpan(1),
|
||||
Textarea::make('app_footer')->label('Custom Footer')->rows(6)->columnSpan(1),
|
||||
]),
|
||||
Section::make('Meta Information')
|
||||
->description('Change Website Meta Information')
|
||||
->collapsed()
|
||||
->schema([
|
||||
TextInput::make('app_title')->label('Title')->required(),
|
||||
Textarea::make('app_description')->label('Description')->rows(3),
|
||||
TextInput::make('app_keyword')->label('Keyword'),
|
||||
KeyValue::make('app_meta')
|
||||
->label('Meta (Optional)')
|
||||
->keyPlaceholder('Name')
|
||||
->valuePlaceholder('Content'),
|
||||
]),
|
||||
Section::make('Social Links')
|
||||
->description('Enter your social links')
|
||||
->collapsed()
|
||||
->schema([
|
||||
|
||||
Repeater::make('app_social')
|
||||
->statePath('app_social')
|
||||
->schema([
|
||||
TextInput::make('icon')->label('Icon')->required()->maxLength(100),
|
||||
TextInput::make('url')->label('URL')->url()->required()->maxLength(255),
|
||||
]),
|
||||
|
||||
]),
|
||||
Section::make('Ad Spaces')
|
||||
->description('You can setup your Ad Codes here for various Ad Spaces')
|
||||
->collapsed()
|
||||
->schema([
|
||||
Textarea::make('ads_settings.one')->label('Ad Space 1')->rows(4),
|
||||
Textarea::make('ads_settings.two')->label('Ad Space 2')->rows(4),
|
||||
Textarea::make('ads_settings.three')->label('Ad Space 3')->rows(4),
|
||||
Textarea::make('ads_settings.four')->label('Ad Space 4')->rows(4),
|
||||
Textarea::make('ads_settings.five')->label('Ad Space 5')->rows(4),
|
||||
]),
|
||||
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user