/** * @param PersonId $id * @return Person|null */ public function find(PersonId $id) { $result = $this->query('SELECT * FROM people WHERE id = :id', ['id' => $id->toString()]); if (!$result) { return null; } $data = $result[0]; $data['data'] = $this->query('SELECT * FROM people_data WHERE person_id = :id', ['id' => $id->toString()]); $data['tags'] = $this->query('SELECT * FROM tags WHERE person_id = :id', ['id' => $id->toString()]); return Person::fromDB($data); }
/** * @inheritdoc */ public function jsonSerialize() { // YES! This is horrible, sorry, just needed a very quick fix! $canonical = $this->canonical; $filename = sprintf('%s/front/images/people/%s.jpg', public_path(), $canonical); if (!file_exists($filename)) { $canonical = 'blank'; } return ['id' => $this->id->toString(), 'name' => $this->name, 'canonical' => $canonical, 'data' => $this->data, 'tags' => $this->tags]; }