mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-11 02:36:42 +02:00
feat: add platforms form in podcast settings
- set and remove platform links for a podcast - remove unnecessary fields from platforms and platform_links tables - add platforms svg icons to show in form - update platform and auth seeders - update svgo config for images
This commit is contained in:
parent
9a5d5a15b4
commit
043f49c784
44 changed files with 699 additions and 329 deletions
|
|
@ -35,4 +35,55 @@ class PlatformModel extends Model
|
|||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $useTimestamps = true;
|
||||
|
||||
public function getPlatformsWithLinks()
|
||||
{
|
||||
return $this->select(
|
||||
'platforms.*, platform_links.link_url, platform_links.visible'
|
||||
)
|
||||
->join(
|
||||
'platform_links',
|
||||
'platform_links.platform_id = platforms.id',
|
||||
'left'
|
||||
)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
public function savePlatformLinks($podcastId, $platformLinksData)
|
||||
{
|
||||
// Remove already previously set platforms to overwrite them
|
||||
$this->db
|
||||
->table('platform_links')
|
||||
->delete(['podcast_id' => $podcastId]);
|
||||
|
||||
// Set platformLinks
|
||||
return $this->db
|
||||
->table('platform_links')
|
||||
->insertBatch($platformLinksData);
|
||||
}
|
||||
|
||||
public function getPlatformId($platform)
|
||||
{
|
||||
if (is_numeric($platform)) {
|
||||
return (int) $platform;
|
||||
}
|
||||
|
||||
$p = $this->where('name', $platform)->first();
|
||||
|
||||
if (!$p) {
|
||||
$this->error = lang('Platform.platformNotFound', [$platform]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) $p->id;
|
||||
}
|
||||
|
||||
public function removePlatformLink($podcastId, $platformId)
|
||||
{
|
||||
return $this->db->table('platform_links')->delete([
|
||||
'podcast_id' => $podcastId,
|
||||
'platform_id' => $platformId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue