diff --git a/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php b/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php index 0ae167d..d8fe192 100644 --- a/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php +++ b/web/Modules/Customer/App/Filament/Resources/DatabaseResource.php @@ -138,6 +138,10 @@ class DatabaseResource extends Resource ->label('Database Server') ->sortable(), + Tables\Columns\TextColumn::make('hostingSubscription.domain') + ->searchable() + ->sortable(), + ]) ->filters([ // diff --git a/web/Modules/Customer/App/Filament/Resources/HostingSubscriptionBackupResource.php b/web/Modules/Customer/App/Filament/Resources/HostingSubscriptionBackupResource.php new file mode 100644 index 0000000..b6278a4 --- /dev/null +++ b/web/Modules/Customer/App/Filament/Resources/HostingSubscriptionBackupResource.php @@ -0,0 +1,86 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('backup_type') + ->state(function (HostingSubscriptionBackup $backup) { + return ucfirst($backup->backup_type); + }), + + Tables\Columns\BadgeColumn::make('status') + ->badge(), + + Tables\Columns\TextColumn::make('completed_at') + ->state(function (HostingSubscriptionBackup $backup) { + return $backup->completed_at ? $backup->completed_at : 'N/A'; + }), + + Tables\Columns\TextColumn::make('size') + ->state(function (HostingSubscriptionBackup $backup) { + return $backup->size ? $backup->size : 'N/A'; + }), + + Tables\Columns\TextColumn::make('hostingSubscription.domain') + ->searchable() + ->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\ListHostingSubscriptionBackups::route('/'), + 'create' => Pages\CreateHostingSubscriptionBackup::route('/create'), + 'edit' => Pages\EditHostingSubscriptionBackup::route('/{record}/edit'), + ]; + } +} diff --git a/web/Modules/Customer/App/Filament/Resources/HostingSubscriptionBackupResource/Pages/CreateHostingSubscriptionBackup.php b/web/Modules/Customer/App/Filament/Resources/HostingSubscriptionBackupResource/Pages/CreateHostingSubscriptionBackup.php new file mode 100644 index 0000000..0600520 --- /dev/null +++ b/web/Modules/Customer/App/Filament/Resources/HostingSubscriptionBackupResource/Pages/CreateHostingSubscriptionBackup.php @@ -0,0 +1,12 @@ + BackupStatus::class, ]; + protected static function booted(): void + { + static::addGlobalScope('customer', function (Builder $query) { + if (auth()->check() && auth()->guard()->name == 'web_customer') { + $query->whereHas('hostingSubscription', function ($query) { + $query->where('customer_id', auth()->user()->id); + }); + } + }); + } public static function boot() { parent::boot(); @@ -239,4 +250,9 @@ class HostingSubscriptionBackup extends Model } } + + public function hostingSubscription() + { + return $this->belongsTo(HostingSubscription::class); + } }