slug = $slug; $this->db = $db; if (!$this->load_from_slug()) { return false; } else { return true; } } private function load_from_slug(): bool { $dj = $this->get_dj_by_slug($this->slug); if ($dj) { if (isset($dj['id'])) { $this->id = $dj['id']; } if (isset($dj['name'])) { $this->name = $dj['name']; } if (isset($dj['bio'])) { $this->bio = $dj['bio']; } if (isset($dj['img'])) { $this->img = $dj['img']; } if (isset($dj['email'])) { $this->email = $dj['email']; } if (isset($dj['socials'])) { $this->socials = json_decode($dj['socials'], true) ?? []; } if (isset($dj['created'])) { $this->created = $dj['created']; } if (isset($dj['updated'])) { $this->updated = $dj['updated']; } return true; } else { return false; } } private function get_dj_by_slug($slug) { $stmt = $this->db->prepare("SELECT * FROM djs WHERE slug = ?"); $stmt->bind_param("s", $slug); $stmt->execute(); $result = $stmt->get_result(); $dj = $result->fetch_assoc(); $stmt->close(); return $dj; } public function get_slug(): string { return $this->slug; } public function get_id(): int { return $this->id; } public function get_name(): string { return $this->name; } public function get_bio(): string { return $this->bio; } public function get_img(): string { return $this->img; } public function get_active(): bool { return $this->active; } public function get_email(): string { return $this->email; } public function get_socials(): array { return $this->socials; } public function get_created(): string { return $this->created; } public function get_updated(): string { return $this->updated; } }