mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-01 00:17:22 +02:00
- add podcast sidebar navigation - add podcast dashboard with latest episodes - add pagination to podcast episodes - add components helper to reuse ui components (button, data_table, etc.) - enhance podcast and episode forms by splitting them into form sections - add hint tooltips to podcast and episode forms - transform radio inputs as buttons for better ux - replace explicit field by parental_advisory - replace author field by publisher - add podcasts_categories table to set multiple categories - use choices.js to enhance multiselect fields - update Language files - update js dependencies to latest versions closes #31, #9
80 lines
1.8 KiB
PHP
80 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Entities;
|
|
|
|
use App\Models\PodcastModel;
|
|
|
|
class User extends \Myth\Auth\Entities\User
|
|
{
|
|
/**
|
|
* Per-user podcasts
|
|
* @var \App\Entities\Podcast[]
|
|
*/
|
|
protected $podcasts = [];
|
|
|
|
/**
|
|
* The podcast the user is contributing to
|
|
* @var \App\Entities\Podcast|null
|
|
*/
|
|
protected $podcast = null;
|
|
|
|
/**
|
|
* Array of field names and the type of value to cast them as
|
|
* when they are accessed.
|
|
*/
|
|
protected $casts = [
|
|
'active' => 'boolean',
|
|
'force_pass_reset' => 'boolean',
|
|
'podcast_role' => '?string',
|
|
'podcast_id' => '?integer',
|
|
];
|
|
|
|
/**
|
|
* Returns the podcasts the user is contributing to
|
|
*
|
|
* @return \App\Entities\Podcast[]
|
|
*/
|
|
public function getPodcasts()
|
|
{
|
|
if (empty($this->id)) {
|
|
throw new \RuntimeException(
|
|
'Users must be created before getting podcasts.'
|
|
);
|
|
}
|
|
|
|
if (empty($this->podcasts)) {
|
|
$this->podcasts = (new PodcastModel())->getUserPodcasts($this->id);
|
|
}
|
|
|
|
return $this->podcasts;
|
|
}
|
|
|
|
/**
|
|
* Returns a podcast the user is contributing to
|
|
*
|
|
* @return \App\Entities\Podcast
|
|
*/
|
|
public function getPodcast()
|
|
{
|
|
if (empty($this->podcast_id)) {
|
|
throw new \RuntimeException(
|
|
'Podcast_id must be set before getting podcast.'
|
|
);
|
|
}
|
|
|
|
if (empty($this->podcast)) {
|
|
$this->podcast = (new PodcastModel())->getPodcastById(
|
|
$this->podcast_id
|
|
);
|
|
}
|
|
|
|
return $this->podcast;
|
|
}
|
|
}
|