-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #331 from liberu-billing/sweep/Enhance-Hosting-Inf…
…rastructure-with-Multi-Server-Support-and-Product-Type-Management Enhance Hosting Infrastructure with Multi-Server Support and Product Type Management
- Loading branch information
Showing
5 changed files
with
296 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
|
||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\HostingServerResource\Pages; | ||
use App\Models\HostingServer; | ||
use Filament\Forms; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class HostingServerResource extends Resource | ||
{ | ||
protected static ?string $model = HostingServer::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-server'; | ||
protected static ?string $navigationGroup = 'Hosting'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\Card::make() | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('hostname') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\Select::make('control_panel') | ||
->options([ | ||
'cpanel' => 'cPanel', | ||
'plesk' => 'Plesk', | ||
'directadmin' => 'DirectAdmin', | ||
'virtualmin' => 'Virtualmin', | ||
]) | ||
->required(), | ||
Forms\Components\TextInput::make('api_token') | ||
->required() | ||
->password() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('api_url') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\Toggle::make('is_active') | ||
->default(true), | ||
Forms\Components\TextInput::make('max_accounts') | ||
->numeric() | ||
->default(0) | ||
->minValue(0), | ||
]) | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('hostname') | ||
->searchable(), | ||
Tables\Columns\BadgeColumn::make('control_panel') | ||
->colors([ | ||
'primary' => 'cpanel', | ||
'success' => 'plesk', | ||
'warning' => 'directadmin', | ||
'danger' => 'virtualmin', | ||
]), | ||
Tables\Columns\IconColumn::make('is_active') | ||
->boolean(), | ||
Tables\Columns\TextColumn::make('active_accounts') | ||
->label('Active/Max Accounts') | ||
->formatStateUsing(fn ($record) => "{$record->active_accounts}/{$record->max_accounts}"), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->filters([ | ||
Tables\Filters\SelectFilter::make('control_panel') | ||
->options([ | ||
'cpanel' => 'cPanel', | ||
'plesk' => 'Plesk', | ||
'directadmin' => 'DirectAdmin', | ||
'virtualmin' => 'Virtualmin', | ||
]), | ||
Tables\Filters\TernaryFilter::make('is_active') | ||
->label('Active Status'), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListHostingServers::route('/'), | ||
'create' => Pages\CreateHostingServer::route('/create'), | ||
'edit' => Pages\EditHostingServer::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
database/migrations/2024_01_20_000001_create_product_types_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
|
||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('product_types', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('slug')->unique(); | ||
$table->text('description')->nullable(); | ||
$table->boolean('is_recurring')->default(true); | ||
$table->boolean('requires_server')->default(false); | ||
$table->timestamps(); | ||
}); | ||
|
||
// Insert default product types | ||
DB::table('product_types')->insert([ | ||
[ | ||
'name' => 'One Time', | ||
'slug' => 'one-time', | ||
'is_recurring' => false, | ||
'requires_server' => false, | ||
], | ||
[ | ||
'name' => 'Shared Hosting', | ||
'slug' => 'shared-hosting', | ||
'is_recurring' => true, | ||
'requires_server' => true, | ||
], | ||
[ | ||
'name' => 'VPS', | ||
'slug' => 'vps', | ||
'is_recurring' => true, | ||
'requires_server' => true, | ||
], | ||
[ | ||
'name' => 'Dedicated Server', | ||
'slug' => 'dedicated', | ||
'is_recurring' => true, | ||
'requires_server' => true, | ||
], | ||
]); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('product_types'); | ||
} | ||
}; |
31 changes: 31 additions & 0 deletions
31
database/migrations/2024_01_20_000002_create_hosting_servers_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
|
||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('hosting_servers', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('hostname'); | ||
$table->enum('control_panel', ['cpanel', 'plesk', 'directadmin', 'virtualmin']); | ||
$table->string('api_token'); | ||
$table->string('api_url'); | ||
$table->boolean('is_active')->default(true); | ||
$table->integer('max_accounts')->default(0); | ||
$table->integer('active_accounts')->default(0); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('hosting_servers'); | ||
} | ||
}; |
Oops, something went wrong.