Newer
Older

Yassine Doghri
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?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;
}
}