This commit is contained in:
Cody Cook 2024-05-19 20:01:13 -07:00
commit 70c8a87e15
25 changed files with 508 additions and 187 deletions

View file

@ -9,7 +9,7 @@ class DJ
private string $name = "";
private string $bio = "";
private string $slug = "";
private string $img = "img/no-image1.png";
private string $img = "/img/no-image1.png";
private bool $active = false;
private bool $claimed = false;
private string $email = "";
@ -17,7 +17,7 @@ class DJ
private string $created = "";
private string $updated = "";
private string $claimed_by = "";
private string $claimedBy = "";
private $db;
private array $mixes = [];
@ -27,22 +27,21 @@ class DJ
$this->db = $db;
if (ctype_digit((string)$value)) {
$this->id = (int)$value;
return $this->load_from_id();
return $this->loadByID();
} else {
$this->slug = $value;
return $this->load_from_slug();
return $this->loadBySlug();
}
}
private function load_from_id(): bool
private function loadByID(): bool
{
$socials = [];
$dj = $this->get_dj_by_id($this->id);
return $this->build_dj($dj);
$dj = $this->getDJbyID($this->id);
return $this->buildDJ($dj);
}
private function get_dj_by_id()
private function getDJbyID()
{
$stmt = $this->db->prepare("SELECT * FROM djs WHERE id = ?");
$stmt->bind_param("i", $this->id);
@ -57,7 +56,7 @@ class DJ
* @param $dj
* @return bool
*/
private function build_dj($dj): bool
private function buildDJ($dj): bool
{
if ($dj) {
if (isset($dj['id'])) {
@ -130,7 +129,7 @@ class DJ
$this->updated = $dj['lastupdated'];
}
$this->load_dj_mixes();
$this->loadDJMixes();
return true;
} else {
@ -138,7 +137,7 @@ class DJ
}
}
private function load_dj_mixes(): void
private function loadDJMixes(): void
{
$stmt = $this->db->prepare("SELECT * FROM mix WHERE dj1 = ? OR dj2 = ? OR dj3 = ?");
$stmt->bind_param("iii", $this->id, $this->id, $this->id);
@ -154,14 +153,14 @@ class DJ
}
private function load_from_slug(): bool
private function loadBySlug(): bool
{
$socials = [];
$dj = $this->get_dj_by_slug($this->slug);
return $this->build_dj($dj);
$dj = $this->getDJbySlug($this->slug);
return $this->buildDJ($dj);
}
private function get_dj_by_slug($slug)
private function getDJbySlug($slug)
{
$stmt = $this->db->prepare("SELECT * FROM djs WHERE slug = ?");
$stmt->bind_param("s", $slug);
@ -172,63 +171,70 @@ class DJ
return $dj;
}
public function get_slug(): string
public function getSlug(): string
{
return $this->slug;
}
public function get_id(): int
public function getID(): int
{
return $this->id;
}
public function get_name(): string
public function getName(): string
{
return $this->name;
}
public function get_bio(): string
public function getBio(): string
{
return $this->bio;
}
public function get_img(): string
public function getImg(): string
{
return $this->img;
}
public function get_active(): bool
public function getActive(): bool
{
return $this->active;
}
public function get_email(): string
public function getEmail(): string
{
return $this->email;
}
public function get_socials(): array
public function getSocials(): array
{
return $this->socials;
}
public function get_created(): string
public function getCreated(): string
{
return $this->created;
}
public function get_updated(): string
public function getUpdated(): string
{
return $this->updated;
}
public function get_claimed(): bool
public function getClaimed(): bool
{
return $this->claimed;
}
public function get_dj_mixes()
public function getDJMixes()
{
return $this->mixes;
}
public function getClaimedBy()
{
return $this->claimedBy;
}
}