From 10f04df2d2ae84e1f9d77bc5290dc5d232096eae Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Fri, 26 Apr 2024 17:14:31 +0300 Subject: [PATCH] update --- .../Filament/Resources/DatabaseResource.php | 84 +++++++++++++++++++ .../DatabaseResource/Pages/CreateDatabase.php | 12 +++ .../DatabaseResource/Pages/EditDatabase.php | 19 +++++ .../DatabaseResource/Pages/ListDatabases.php | 19 +++++ .../App/Providers/CustomerServiceProvider.php | 2 +- .../Filament/CustomerPanelProvider.php | 8 +- 6 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 web/Modules/Customer/App/Filament/Resources/DatabaseResource.php create mode 100644 web/Modules/Customer/App/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php create mode 100644 web/Modules/Customer/App/Filament/Resources/DatabaseResource/Pages/EditDatabase.php create mode 100644 web/Modules/Customer/App/Filament/Resources/DatabaseResource/Pages/ListDatabases.php rename web/Modules/Customer/{ => App}/Providers/Filament/CustomerPanelProvider.php (87%) diff --git a/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php b/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php new file mode 100644 index 0000000..4f14a79 --- /dev/null +++ b/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php @@ -0,0 +1,84 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + + Tables\Columns\TextColumn::make('database_name') + ->prefix(function ($record) { + return $record->database_name_prefix; + }) + ->label('Database Name') + ->searchable() + ->sortable(), + + Tables\Columns\TextColumn::make('databaseUsers.username') + ->label('Database Users') + ->listWithLineBreaks() + ->limitList(2) + ->expandableLimitedList(), + + Tables\Columns\TextColumn::make('is_remote_database_server') + ->badge() + ->state(fn($record) => $record->is_remote_database_server ? 'Remote Database Server' : 'Internal Database Server') + ->label('Database Server') + ->sortable(), + + ]) + ->filters([ + // + ]) + ->actions([ + 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\ListDatabases::route('/'), + 'create' => Pages\CreateDatabase::route('/create'), + 'edit' => Pages\EditDatabase::route('/{record}/edit'), + ]; + } +} diff --git a/web/Modules/Customer/App/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php b/web/Modules/Customer/App/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php new file mode 100644 index 0000000..b47e0c1 --- /dev/null +++ b/web/Modules/Customer/App/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php @@ -0,0 +1,12 @@ +colors([ 'primary'=>$defaultColor, ]) - ->discoverResources(in: module_path($this->module, 'Filament/Admin/Resources'), for: "$moduleNamespace\\Filament\\Admin\\Resources") - ->discoverPages(in: module_path($this->module, 'Filament/Admin/Pages'), for: "$moduleNamespace\\Filament\\Admin\\Pages") + ->discoverResources(in: module_path($this->module, 'App/Filament/Resources'), for: "$moduleNamespace\\App\\Filament\\Resources") + ->discoverPages(in: module_path($this->module, 'App/Filament/Pages'), for: "$moduleNamespace\\App\Filament\\Pages") ->pages([ Pages\Dashboard::class, ]) - ->discoverWidgets(in: module_path($this->module, 'Filament/Admin/Widgets'), for: "$moduleNamespace\\Filament\\Admin\\Widgets") + ->discoverWidgets(in: module_path($this->module, 'App/Filament/Widgets'), for: "$moduleNamespace\\App\Filament\\Widgets") ->widgets([ Widgets\AccountWidget::class, Widgets\FilamentInfoWidget::class,