castopod/app/Entities/User.php
Yassine Doghri 58364bfed1 refactor(auth): change contributor's role logic to have it included in the users_podcasts table
- update myth-auth and codeigniter to latest develop changes
- improve permission check: remove all
dynamic permissions per podcast and overwrite myth-auth services and permission filter
- remove
unnecessary code because of myth-auth upgrade
- refactor some controller code for better clarity
-
add remaining seeders in docs

closes #19, #20
2020-10-15 14:41:14 +00:00

43 lines
961 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;
}
}