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

- update CI process to include quality stage (tests + code review) - add captainhook to install git pre-commit & pre-push hooks - remove .devcontainer Dockerfile to use project's docker-compose services: all services can now be started automatically using vscode - update docs/setup-development.md
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Entities\User;
|
|
class UserModel extends \Myth\Auth\Models\UserModel
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $returnType = User::class;
|
|
|
|
public function getPodcastContributors($podcastId)
|
|
{
|
|
$cacheName = "podcast#{$podcastId}_contributors";
|
|
if (!($found = cache($cacheName))) {
|
|
$found = $this->select('users.*, auth_groups.name as podcast_role')
|
|
->join('podcasts_users', 'podcasts_users.user_id = users.id')
|
|
->join(
|
|
'auth_groups',
|
|
'auth_groups.id = podcasts_users.group_id',
|
|
)
|
|
->where('podcasts_users.podcast_id', $podcastId)
|
|
->findAll();
|
|
|
|
cache()->save($cacheName, $found, DECADE);
|
|
}
|
|
|
|
return $found;
|
|
}
|
|
|
|
public function getPodcastContributor($user_id, $podcast_id)
|
|
{
|
|
return $this->select(
|
|
'users.*, podcasts_users.podcast_id as podcast_id, auth_groups.name as podcast_role',
|
|
)
|
|
->join('podcasts_users', 'podcasts_users.user_id = users.id')
|
|
->join('auth_groups', 'auth_groups.id = podcasts_users.group_id')
|
|
->where([
|
|
'users.id' => $user_id,
|
|
'podcast_id' => $podcast_id,
|
|
])
|
|
->first();
|
|
}
|
|
}
|