Add session key to use last used node, instead of latest created node (#1869)

Co-authored-by: Lance Pioch <git@lance.sh>
This commit is contained in:
Charles 2025-11-08 17:09:41 -05:00 committed by GitHub
parent b06df23823
commit a30c45fbbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -116,6 +116,14 @@ class CreateServer extends CreateRecord
->prefixIcon('tabler-server-2')
->selectablePlaceholder(false)
->default(function () {
$lastUsedNode = session()->get('last_utilized_node');
if ($lastUsedNode && user()?->accessibleNodes()->where('id', $lastUsedNode)->exists()) {
$this->node = Node::find($lastUsedNode);
return $this->node?->id;
}
/** @var ?Node $latestNode */
$latestNode = user()?->accessibleNodes()->latest()->first();
$this->node = $latestNode;
@ -829,6 +837,8 @@ class CreateServer extends CreateRecord
$data['allocation_additional'] = collect($allocation_additional)->filter()->all();
}
session()->put('last_utilized_node', $data['node_id']);
try {
return $this->serverCreationService->handle($data);
} catch (Exception $exception) {