feat(mail-campaigns): sender info + resolve typed emails against customers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
54c14c41d8
commit
e1efc88fd2
@@ -349,7 +349,7 @@ class CustomerServiceProvisioningService
|
||||
* List virtual machines from vCenter inventory for the VPS picker.
|
||||
* Annotates each VM with `assigned_service_id` if already linked to a service.
|
||||
*/
|
||||
public function listAvailableVms(string $search): Collection
|
||||
public function listAvailableVms(string $search, int $page = 1, int $perPage = 200): array
|
||||
{
|
||||
$assignments = DB::table('module_vmware as mv')
|
||||
->join('services as s', 's.vm_id', '=', 'mv.id')
|
||||
@@ -358,25 +358,29 @@ class CustomerServiceProvisioningService
|
||||
->get()
|
||||
->keyBy('virtual_machine_id');
|
||||
|
||||
return DB::table('virtual_machines as vm')
|
||||
$query = DB::table('virtual_machines as vm')
|
||||
->leftJoin('module_datacenter as dc', 'dc.id', '=', 'vm.datacenter_id')
|
||||
->leftJoin('module_host as h', 'h.id', '=', 'vm.host_id')
|
||||
->leftJoin('module_vcenter as vc', 'vc.id', '=', 'dc.vcenter_id')
|
||||
->select(
|
||||
'vm.id', 'vm.vm_id', 'vm.name', 'vm.power_state', 'vm.cpu', 'vm.ram_mb', 'vm.ip',
|
||||
'vc.host as vcenter_name',
|
||||
'dc.name as datacenter_name',
|
||||
'h.name as host_name',
|
||||
)
|
||||
->where('vm.is_template', 0)
|
||||
->where('vm.is_system', 0)
|
||||
->when($search, fn($q) => $q->where(function ($w) use ($search) {
|
||||
$w->where('vm.name', 'like', "%{$search}%")
|
||||
->orWhere('vm.vm_id', 'like', "%{$search}%")
|
||||
->orWhere('vm.ip', 'like', "%{$search}%");
|
||||
}))
|
||||
}));
|
||||
|
||||
$total = (clone $query)->count();
|
||||
|
||||
$data = $query
|
||||
->select(
|
||||
'vm.id', 'vm.vm_id', 'vm.name', 'vm.power_state', 'vm.cpu', 'vm.ram_mb', 'vm.ip',
|
||||
'vc.host as vcenter_name',
|
||||
'dc.name as datacenter_name',
|
||||
'h.name as host_name',
|
||||
)
|
||||
->orderBy('vm.name')
|
||||
->limit(200)
|
||||
->forPage($page, $perPage)
|
||||
->get()
|
||||
->map(function ($vm) use ($assignments) {
|
||||
$a = $assignments->get($vm->id);
|
||||
@@ -384,5 +388,7 @@ class CustomerServiceProvisioningService
|
||||
$vm->assigned_customer_id = $a->service_customer_id ?? null;
|
||||
return $vm;
|
||||
});
|
||||
|
||||
return ['data' => $data, 'total' => $total];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user