List artwork by artist via /artworks/<artist-name>

This commit is contained in:
Mike Colagrosso 2024-01-22 21:24:01 -07:00 committed by Alex Cabal
parent 780be15ed0
commit cad2f5f730
8 changed files with 63 additions and 12 deletions

View file

@ -4,6 +4,7 @@ use function Safe\date;
/**
* @property string $UrlName
* @property string $Url
* @property array<string> $AlternateNames
* @property array<string> $_AlternateNames
*/
@ -14,6 +15,7 @@ class Artist extends PropertiesBase{
public ?datetime $Created = null;
public ?datetime $Updated = null;
protected ?string $_UrlName = null;
protected ?string $_Url = null;
protected $_AlternateNames;
// *******
@ -32,6 +34,14 @@ class Artist extends PropertiesBase{
return $this->_UrlName;
}
protected function GetUrl(): string{
if($this->_Url === null){
$this->_Url = '/artworks/' . $this->UrlName;
}
return $this->_Url;
}
/**
* @return array<string>
*/

View file

@ -247,6 +247,20 @@ class Library{
return $artworks;
}
/**
* @return array<Artwork>
*/
public static function GetArtworkByArtist(string $artistUrlName): array{
$artworks = Db::Query('
SELECT art.*
from Artworks art
inner join Artists a using (ArtistId)
where a.UrlName = ?
order by art.Created desc', [$artistUrlName], 'Artwork');
return $artworks;
}
/**
* @return array<mixed>
*/