Implement Item->getJson();

This commit is contained in:
Dendy 2023-07-10 06:14:29 +02:00
parent da43b49abf
commit 2cc6c7d0ee
1 changed files with 11 additions and 6 deletions

View File

@ -41,7 +41,7 @@ function get_item()
Json::error('No item was found with the given ID')->die();
}
return Json::new($item->getUri());
return $item->getJson();
}
function post_item()
@ -49,11 +49,7 @@ function post_item()
// The checks are performed internally
$item = Item::upload($_FILES['file']);
return Json::new([
'type' => 'success',
'id' => $item->getHash(),
'link' => $item->getUri(),
]);
return $item->getJson();
};
class MediaDB
@ -237,6 +233,15 @@ class Item
$this->extension,
);
}
public function getJson(): Json
{
return Json::new([
'id' => $this->hash,
'link' => $this->getUri(),
'tags' => $this->tags,
]);
}
}
class Json