Added imap_setting to Setting Page
This commit is contained in:
@@ -4,9 +4,11 @@ namespace App\Filament\Pages;
|
|||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\Checkbox;
|
||||||
use Filament\Forms\Components\KeyValue;
|
use Filament\Forms\Components\KeyValue;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
@@ -34,6 +36,7 @@ class Settings extends Page implements HasForms
|
|||||||
$setting = Setting::where('app_admin', $auth_email)->first();
|
$setting = Setting::where('app_admin', $auth_email)->first();
|
||||||
|
|
||||||
if ($setting) {
|
if ($setting) {
|
||||||
|
$imapSettings = $setting->imap_settings ?? [];
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'app_name' => $setting->app_name,
|
'app_name' => $setting->app_name,
|
||||||
'app_version' => $setting->app_version,
|
'app_version' => $setting->app_version,
|
||||||
@@ -46,7 +49,8 @@ class Settings extends Page implements HasForms
|
|||||||
'app_meta' => $setting->app_meta,
|
'app_meta' => $setting->app_meta,
|
||||||
'app_social' => $setting->app_social,
|
'app_social' => $setting->app_social,
|
||||||
'app_header' => $setting->app_header,
|
'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_admin' => $auth_email,
|
||||||
'app_social' => [
|
'app_social' => [
|
||||||
null => null,
|
null => null,
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +68,7 @@ class Settings extends Page implements HasForms
|
|||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('Website Infomation')
|
Section::make('Website Information')
|
||||||
->description('Change Basic Website Information')
|
->description('Change Basic Website Information')
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->schema([
|
->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');
|
->statePath('data');
|
||||||
}
|
}
|
||||||
@@ -159,6 +182,7 @@ class Settings extends Page implements HasForms
|
|||||||
'app_description' => $data['app_description'],
|
'app_description' => $data['app_description'],
|
||||||
'app_keyword' => $data['app_keyword'],
|
'app_keyword' => $data['app_keyword'],
|
||||||
'app_social' => $data['app_social'],
|
'app_social' => $data['app_social'],
|
||||||
|
'imap_settings' => $data['imap_settings'],
|
||||||
];
|
];
|
||||||
$create_res = Setting::create(array_merge($data));
|
$create_res = Setting::create(array_merge($data));
|
||||||
|
|
||||||
@@ -171,7 +195,7 @@ class Settings extends Page implements HasForms
|
|||||||
}
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Something went wrong')
|
->title('Something went wrong '.$exception->getMessage())
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ class Setting extends Model
|
|||||||
'app_social',
|
'app_social',
|
||||||
'app_header',
|
'app_header',
|
||||||
'app_footer',
|
'app_footer',
|
||||||
|
'imap_settings',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'app_meta' => 'json',
|
'app_meta' => 'json',
|
||||||
'app_social' => 'json'
|
'app_social' => 'json',
|
||||||
|
'imap_settings' => 'json',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('settings', function (Blueprint $table) {
|
||||||
|
$table->json('imap_settings')->default('[]')->after('app_footer');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('imap_settings');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user