mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-25 20:08:23 +02:00
Tiny updates to the control panel
This commit is contained in:
parent
29400f319f
commit
4abca19ba3
7 changed files with 229 additions and 25 deletions
59
cp/app/Models/Host.php
Normal file
59
cp/app/Models/Host.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Pinga\Db\PdoDatabase;
|
||||
|
||||
class Host
|
||||
{
|
||||
private PdoDatabase $db;
|
||||
|
||||
public function __construct(PdoDatabase $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public function getAllHost()
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
host.*,
|
||||
addr.addr,
|
||||
addr.ip,
|
||||
status.status AS host_status,
|
||||
CASE WHEN EXISTS (
|
||||
SELECT 1 FROM domain_host_map WHERE domain_host_map.host_id = host.id
|
||||
) THEN 1 ELSE 0 END AS has_domain_mapping
|
||||
FROM host
|
||||
LEFT JOIN host_addr AS addr ON host.id = addr.host_id
|
||||
LEFT JOIN host_status AS status ON host.id = status.host_id
|
||||
";
|
||||
|
||||
return $this->db->select($sql);
|
||||
}
|
||||
|
||||
public function getHostById($id)
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
host.*,
|
||||
addr.addr,
|
||||
addr.ip,
|
||||
status.status AS host_status,
|
||||
domainMap.domain_id
|
||||
FROM host
|
||||
LEFT JOIN host_addr AS addr ON host.id = addr.host_id
|
||||
LEFT JOIN host_status AS status ON host.id = status.host_id
|
||||
LEFT JOIN domain_host_map AS domainMap ON host.id = domainMap.host_id
|
||||
WHERE host.id = ?
|
||||
";
|
||||
|
||||
return $this->db->select($sql, [$id])->fetch();
|
||||
}
|
||||
|
||||
public function deleteHost($id)
|
||||
{
|
||||
$this->db->delete('DELETE FROM host WHERE id = ?', [$id]);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue