diff --git a/web/app/Filament/Resources/HostingSubscriptionResource.php b/web/app/Filament/Resources/HostingSubscriptionResource.php index 2227002..0b033c2 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources; use App\Filament\Resources\HostingSubscriptionResource\Pages; +use app\Filament\Resources\HostingSubscriptionResource\Pages\ManageHostingSubscriptionFtpAccounts; use App\Models\Customer; use App\Models\Domain; use App\Models\HostingSubscription; @@ -188,6 +189,7 @@ class HostingSubscriptionResource extends Resource Pages\EditHostingSubscription::class, Pages\ManageHostingSubscriptionDatabases::class, Pages\ManageHostingSubscriptionBackups::class, + ManageHostingSubscriptionFtpAccounts::class ]); } @@ -207,6 +209,7 @@ class HostingSubscriptionResource extends Resource 'edit' => Pages\EditHostingSubscription::route('/{record}/edit'), 'databases' => Pages\ManageHostingSubscriptionDatabases::route('/{record}/databases'), 'backups' => Pages\ManageHostingSubscriptionBackups::route('/{record}/backups'), + 'ftp-accounts' => Pages\ManageHostingSubscriptionFtpAccounts::route('/{record}/ftp-accounts'), ]; } diff --git a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php index da99a69..3ec5cf3 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php @@ -47,7 +47,7 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords public static function getNavigationLabel(): string { - return 'Manage Backups'; + return 'Backups'; } public function form(Form $form): Form @@ -99,7 +99,7 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords } return $table - ->recordTitleAttribute('id') + ->recordTitleAttribute('file_name') ->columns([ Tables\Columns\TextColumn::make('backup_type') diff --git a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionDatabases.php b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionDatabases.php index e381f15..7e00cda 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionDatabases.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionDatabases.php @@ -41,7 +41,7 @@ class ManageHostingSubscriptionDatabases extends ManageRelatedRecords public static function getNavigationLabel(): string { - return 'Manage Databases'; + return 'Databases'; } public function form(Form $form): Form diff --git a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionFtpAccounts.php b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionFtpAccounts.php new file mode 100644 index 0000000..e865d35 --- /dev/null +++ b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionFtpAccounts.php @@ -0,0 +1,134 @@ +getRecordTitle(); + + $recordTitle = $recordTitle instanceof Htmlable ? $recordTitle->toHtml() : $recordTitle; + + return "Manage {$recordTitle} FTP Accounts"; + } + + public function getBreadcrumb(): string + { + return 'FTP Accounts'; + } + + public static function getNavigationLabel(): string + { + return 'FTP Accounts'; + } + + public function form(Form $form): Form + { + $systemUsername = $this->record->system_username; + + return $form + ->schema([ + + Forms\Components\TextInput::make('username') + ->label('Username') + ->required(), + + Forms\Components\TextInput::make('password') + ->label('Password') + ->required(), + Forms\Components\TextInput::make('confirm_password') + ->label('Confirm Password') + ->same('password') + ->required(), + + Forms\Components\TextInput::make('path') + ->label('Home Directory') + ->prefix('/home/' . $systemUsername . '/') + ->required(), + + Forms\Components\TextInput::make('quota') + ->label('Quota'), + + Forms\Components\Toggle::make('unlimited_quota') + ->label('Unlimited Quota') + ->default(false), + + ]) + ->columns(1); + } + + public function infolist(Infolist $infolist): Infolist + { + return $infolist + ->columns(1) + ->schema([ + //TextEntry::make('id')->label('id'), + TextEntry::make('username')->label('Username'), + TextEntry::make('path')->label('Home Directory'), + TextEntry::make('quota')->label('Quota'), + IconEntry::make('unlimited_quota')->label('Unlimited Quota'), + + ]); + } + + public function table(Table $table): Table + { + + return $table + ->recordTitleAttribute('username') + ->columns([ + + Tables\Columns\TextColumn::make('username') + ->label('Username'), + + Tables\Columns\TextColumn::make('path') + ->label('Home Directory') + ->default('/'), + + + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), +// + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->groupedBulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/web/app/Models/HostingSubscription.php b/web/app/Models/HostingSubscription.php index 7562c35..6b4e105 100644 --- a/web/app/Models/HostingSubscription.php +++ b/web/app/Models/HostingSubscription.php @@ -64,7 +64,7 @@ class HostingSubscription extends Model if (empty($model->system_username)) { throw new \Exception('System username is empty'); } - + $getLinuxUser = new GetLinuxUser(); $getLinuxUser->setUsername($model->system_username); $getLinuxUserStatus = $getLinuxUser->handle(); @@ -109,6 +109,11 @@ class HostingSubscription extends Model return $this->hasMany(Domain::class); } + public function ftpAccounts() + { + return $this->hasMany(HostingSubscriptionFtpAccount::class); + } + private function _createLinuxWebUser($model): array { $findCustomer = Customer::where('id', $model->customer_id)->first(); diff --git a/web/app/Models/HostingSubscriptionFtpAccount.php b/web/app/Models/HostingSubscriptionFtpAccount.php new file mode 100644 index 0000000..4ec7bcb --- /dev/null +++ b/web/app/Models/HostingSubscriptionFtpAccount.php @@ -0,0 +1,19 @@ +id(); + + $table->bigInteger('hosting_subscription_id')->nullable(); + $table->string('username')->nullable(); + $table->string('password')->nullable(); + $table->string('path')->nullable(); + $table->string('quota')->nullable(); + $table->tinyInteger('unlimited_quota')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('hosting_subscription_ftp_accounts'); + } +};