mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- add .editorconfig file - format all files to comply with castopod's coding style - switch parsedown dependency with commonmark library to better follow commonmark spec for markdown - add prettier command to format all project files at once closes #16
45 lines
962 B
PHP
45 lines
962 B
PHP
<?php
|
|
|
|
namespace App\Entities;
|
|
|
|
use App\Models\PodcastModel;
|
|
|
|
class User extends \Myth\Auth\Entities\User
|
|
{
|
|
/**
|
|
* Per-user podcasts
|
|
* @var \App\Entities\Podcast[]
|
|
*/
|
|
protected $podcasts = [];
|
|
|
|
/**
|
|
* 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',
|
|
];
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|