Added imap_setting to Setting Page
This commit is contained in:
@@ -4,9 +4,11 @@ namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
@@ -34,6 +36,7 @@ class Settings extends Page implements HasForms
|
||||
$setting = Setting::where('app_admin', $auth_email)->first();
|
||||
|
||||
if ($setting) {
|
||||
$imapSettings = $setting->imap_settings ?? [];
|
||||
$this->form->fill([
|
||||
'app_name' => $setting->app_name,
|
||||
'app_version' => $setting->app_version,
|
||||
@@ -46,7 +49,8 @@ class Settings extends Page implements HasForms
|
||||
'app_meta' => $setting->app_meta,
|
||||
'app_social' => $setting->app_social,
|
||||
'app_header' => $setting->app_header,
|
||||
'app_footer' => $setting->app_footer
|
||||
'app_footer' => $setting->app_footer,
|
||||
'imap_settings' => $imapSettings,
|
||||
]);
|
||||
|
||||
|
||||
@@ -55,7 +59,7 @@ class Settings extends Page implements HasForms
|
||||
'app_admin' => $auth_email,
|
||||
'app_social' => [
|
||||
null => null,
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +68,7 @@ class Settings extends Page implements HasForms
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('Website Infomation')
|
||||
Section::make('Website Information')
|
||||
->description('Change Basic Website Information')
|
||||
->collapsible()
|
||||
->schema([
|
||||
@@ -108,6 +112,25 @@ class Settings extends Page implements HasForms
|
||||
])
|
||||
|
||||
]),
|
||||
|
||||
Section::make('Imap')
|
||||
->description('Enter your imap server')
|
||||
->collapsed()
|
||||
->schema([
|
||||
TextInput::make('imap_settings.hostname')->label('Hostname')->required(),
|
||||
TextInput::make('imap_settings.port')->label('Port')->required(),
|
||||
Select::make('imap_settings.encryption')->options([
|
||||
'none' => 'None',
|
||||
'ssl' => 'SSL',
|
||||
'tls' => 'TLS'
|
||||
]),
|
||||
Checkbox::make('imap_settings.validate_cert')->label('Validate Encryption Certificate')->default(false),
|
||||
TextInput::make('imap_settings.username')->label('Username')->required(),
|
||||
TextInput::make('imap_settings.password')->label('Password')->required(),
|
||||
TextInput::make('imap_settings.default_account')->label('Default Account')->default('default')->placeholder('default'),
|
||||
TextInput::make('imap_settings.protocol')->label('Protocol')->default('imap')->placeholder('imap'),
|
||||
Checkbox::make('imap_settings.cc_check')->label('Check CC Field')->default(false)->helperText('If enabled, we will check the CC field as well while fetching mails.'),
|
||||
])
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
@@ -159,6 +182,7 @@ class Settings extends Page implements HasForms
|
||||
'app_description' => $data['app_description'],
|
||||
'app_keyword' => $data['app_keyword'],
|
||||
'app_social' => $data['app_social'],
|
||||
'imap_settings' => $data['imap_settings'],
|
||||
];
|
||||
$create_res = Setting::create(array_merge($data));
|
||||
|
||||
@@ -171,7 +195,7 @@ class Settings extends Page implements HasForms
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Notification::make()
|
||||
->title('Something went wrong')
|
||||
->title('Something went wrong '.$exception->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@ class Setting extends Model
|
||||
'app_social',
|
||||
'app_header',
|
||||
'app_footer',
|
||||
'imap_settings',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'app_meta' => 'json',
|
||||
'app_social' => 'json'
|
||||
'app_social' => 'json',
|
||||
'imap_settings' => 'json',
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user