mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-02 15:51:49 +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
55
cp/app/Models/Contact.php
Normal file
55
cp/app/Models/Contact.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Pinga\Db\PdoDatabase;
|
||||
|
||||
class Contact
|
||||
{
|
||||
private PdoDatabase $db;
|
||||
|
||||
public function __construct(PdoDatabase $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public function getAllContact()
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
contact.*,
|
||||
postalInfo.*,
|
||||
status.status AS contact_status,
|
||||
CASE WHEN EXISTS (
|
||||
SELECT 1 FROM domain_contact_map WHERE domain_contact_map.contact_id = contact.id
|
||||
) THEN 1 ELSE 0 END AS has_domain_contact_mapping
|
||||
FROM contact
|
||||
LEFT JOIN contact_postalInfo AS postalInfo ON contact.id = postalInfo.contact_id
|
||||
LEFT JOIN contact_status AS status ON contact.id = status.contact_id
|
||||
";
|
||||
|
||||
return $this->db->select($sql);
|
||||
}
|
||||
|
||||
public function getContactById($id)
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
contact.*,
|
||||
postalInfo.*,
|
||||
status.status AS contact_status
|
||||
FROM contact
|
||||
LEFT JOIN contact_postalInfo AS postalInfo ON contact.id = postalInfo.contact_id
|
||||
LEFT JOIN contact_status AS status ON contact.id = status.contact_id
|
||||
WHERE contact.id = ?
|
||||
";
|
||||
|
||||
return $this->db->select($sql, [$id])->fetch();
|
||||
}
|
||||
|
||||
public function deleteContact($id)
|
||||
{
|
||||
$this->db->delete('DELETE FROM contact WHERE id = ?', [$id]);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue