From 17bf284b30de37285e6a15f643366fd79842fcb4 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Wed, 18 Sep 2024 20:44:45 +0300 Subject: [PATCH] update --- .../Filament/Resources/EmailBoxResource.php | 129 ++++++++++++++++++ .../EmailBoxResource/Pages/CreateEmailBox.php | 12 ++ .../EmailBoxResource/Pages/EditEmailBox.php | 19 +++ .../EmailBoxResource/Pages/ListEmailBoxes.php | 19 +++ web/Modules/Email/App/Models/EmailBox.php | 24 +++- ..._09_18_130411_create_email_boxes_table.php | 2 +- 6 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 web/Modules/Email/App/Filament/Resources/EmailBoxResource.php create mode 100644 web/Modules/Email/App/Filament/Resources/EmailBoxResource/Pages/CreateEmailBox.php create mode 100644 web/Modules/Email/App/Filament/Resources/EmailBoxResource/Pages/EditEmailBox.php create mode 100644 web/Modules/Email/App/Filament/Resources/EmailBoxResource/Pages/ListEmailBoxes.php diff --git a/web/Modules/Email/App/Filament/Resources/EmailBoxResource.php b/web/Modules/Email/App/Filament/Resources/EmailBoxResource.php new file mode 100644 index 0000000..1afe3b1 --- /dev/null +++ b/web/Modules/Email/App/Filament/Resources/EmailBoxResource.php @@ -0,0 +1,129 @@ +schema([ + + Forms\Components\TextInput::make('username') + ->label('Username') + ->disabled(function ($record) { + return $record->exists; + }) + ->columnSpanFull(), + + Forms\Components\Select::make('domain') + ->label('Domain') + ->options(Domain::get()->pluck('domain', 'domain')->toArray()) + ->columnSpanFull(), + + Forms\Components\TextInput::make('password') + ->label('Password') + ->placeholder('Password for POP3/IMAP') + ->columnSpanFull(), + + Forms\Components\TextInput::make('name') + ->placeholder('Full Name') + ->columnSpanFull(), + +// +// Forms\Components\TextInput::make('maildir') +// ->label('Maildir'), + Forms\Components\TextInput::make('quota') + ->placeholder('MB (max: 10)') + ->columnSpanFull() + ->default(10) + ->label('Quota'), +// +// Forms\Components\TextInput::make('local_part') +// ->label('Local Part'), +// + + Forms\Components\TextInput::make('phone') + ->columnSpanFull() + ->label('Phone'), + + Forms\Components\Checkbox::make('active') + ->label('Active') + ->columnSpanFull(), + +// Forms\Components\TextInput::make('token') +// ->label('Token'), +// Forms\Components\DateTimePicker::make('token_validity') +// ->label('Token Validity'), +// Forms\Components\DateTimePicker::make('password_expiry') +// ->label('Password Expiry'), + +// Forms\Components\Checkbox::make('smtp_active') +// ->label('Smtp Active'), + + + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('email') + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('name') + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('quota') + ->searchable() + ->sortable(), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\DeleteAction::make(), + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ +// Tables\Actions\BulkActionGroup::make([ +// Tables\Actions\DeleteBulkAction::make(), +// ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListEmailBoxes::route('/'), + 'create' => Pages\CreateEmailBox::route('/create'), + 'edit' => Pages\EditEmailBox::route('/{record}/edit'), + ]; + } +} diff --git a/web/Modules/Email/App/Filament/Resources/EmailBoxResource/Pages/CreateEmailBox.php b/web/Modules/Email/App/Filament/Resources/EmailBoxResource/Pages/CreateEmailBox.php new file mode 100644 index 0000000..02fdae3 --- /dev/null +++ b/web/Modules/Email/App/Filament/Resources/EmailBoxResource/Pages/CreateEmailBox.php @@ -0,0 +1,12 @@ +username . '@' . $this->domain; + } } diff --git a/web/Modules/Email/Database/migrations/2024_09_18_130411_create_email_boxes_table.php b/web/Modules/Email/Database/migrations/2024_09_18_130411_create_email_boxes_table.php index e070229..4e8737c 100644 --- a/web/Modules/Email/Database/migrations/2024_09_18_130411_create_email_boxes_table.php +++ b/web/Modules/Email/Database/migrations/2024_09_18_130411_create_email_boxes_table.php @@ -18,7 +18,7 @@ return new class extends Migration $table->string('password')->nullable(); $table->string('name')->nullable(); $table->string('maildir')->nullable(); - $table->bigInteger('quota')->default(0); + $table->bigInteger('quota')->nullable(); $table->string('local_part')->nullable(); $table->string('domain')->nullable(); $table->dateTime('created')->default('2000-01-01 00:00:00');