Add all files
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Servers\Proxmox\Admin\Resources\ServerResource\Pages;
|
||||
|
||||
use App\Models\Service;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Admin\Resources\ServerResource;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Models\IPAddress;
|
||||
|
||||
class CreateServer extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ServerResource::class;
|
||||
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$data['user_id'] = Service::find($data['service_id'])->user_id;
|
||||
|
||||
$record = static::getModel()::create($data);
|
||||
|
||||
// Assign the primary_ipv4 and primary_ipv6 addresses
|
||||
if ($data['primary_ipv4']) {
|
||||
$ip = IPAddress::find($data['primary_ipv4']);
|
||||
$ip->server_id = $record->id;
|
||||
$ip->save();
|
||||
}
|
||||
|
||||
if ($data['primary_ipv6']) {
|
||||
$ip = IPAddress::find($data['primary_ipv6']);
|
||||
$ip->server_id = $record->id;
|
||||
$ip->save();
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Servers\Proxmox\Admin\Resources\ServerResource\Pages;
|
||||
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Admin\Resources\ServerResource;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Proxmox;
|
||||
|
||||
class EditServer extends EditRecord
|
||||
{
|
||||
protected static string $resource = ServerResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\Action::make('reinstall')
|
||||
->label('Reinstall')
|
||||
->action(function () {
|
||||
$proxmox = new Proxmox;
|
||||
$proxmox->reinstall($this->record);
|
||||
|
||||
Notification::make()
|
||||
->title('Reinstalling server')
|
||||
->success()
|
||||
->body('The server is being reinstalled.')
|
||||
->send();
|
||||
})
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->icon('ri-refresh-line'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Servers\Proxmox\Admin\Resources\ServerResource\Pages;
|
||||
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Admin\Resources\ServerResource;
|
||||
|
||||
class ListServers extends ListRecords
|
||||
{
|
||||
protected static string $resource = ServerResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user