2020-06-08 20:32:42 +00:00
|
|
|
<?php
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-06-08 20:32:42 +00:00
|
|
|
|
|
|
|
namespace App\Entities;
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
use App\Models\PodcastModel;
|
2020-06-08 20:32:42 +00:00
|
|
|
use CodeIgniter\Entity;
|
|
|
|
|
|
|
|
class Episode extends Entity
|
|
|
|
{
|
2020-06-26 14:34:52 +00:00
|
|
|
protected $link;
|
|
|
|
protected $image_media_path;
|
|
|
|
protected $image_url;
|
|
|
|
protected $enclosure_media_path;
|
|
|
|
protected $enclosure_url;
|
|
|
|
protected $guid;
|
|
|
|
protected $podcast;
|
|
|
|
|
2020-06-08 20:32:42 +00:00
|
|
|
protected $casts = [
|
|
|
|
'slug' => 'string',
|
|
|
|
'title' => 'string',
|
2020-06-26 14:34:52 +00:00
|
|
|
'enclosure_uri' => 'string',
|
2020-06-08 20:32:42 +00:00
|
|
|
'enclosure_length' => 'integer',
|
|
|
|
'enclosure_type' => 'string',
|
|
|
|
'pub_date' => 'datetime',
|
|
|
|
'description' => 'string',
|
|
|
|
'duration' => 'integer',
|
2020-06-26 14:34:52 +00:00
|
|
|
'image_uri' => 'string',
|
|
|
|
'author_name' => '?string',
|
|
|
|
'author_email' => '?string',
|
2020-06-08 20:32:42 +00:00
|
|
|
'explicit' => 'boolean',
|
2020-06-12 19:31:10 +00:00
|
|
|
'number' => 'integer',
|
2020-06-08 20:32:42 +00:00
|
|
|
'season_number' => '?integer',
|
|
|
|
'type' => 'string',
|
|
|
|
'block' => 'boolean',
|
|
|
|
];
|
2020-06-26 14:34:52 +00:00
|
|
|
|
|
|
|
public function getImageMediaPath()
|
|
|
|
{
|
|
|
|
return media_path($this->attributes['image_uri']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getImageUrl()
|
|
|
|
{
|
|
|
|
return media_url($this->attributes['image_uri']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEnclosureMediaPath()
|
|
|
|
{
|
|
|
|
return media_path($this->attributes['enclosure_uri']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEnclosureUrl()
|
|
|
|
{
|
|
|
|
return base_url(
|
|
|
|
route_to(
|
|
|
|
'analytics_hit',
|
|
|
|
$this->attributes['podcast_id'],
|
|
|
|
$this->attributes['id'],
|
|
|
|
$this->attributes['enclosure_uri']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLink()
|
|
|
|
{
|
|
|
|
return base_url(
|
|
|
|
route_to(
|
|
|
|
'episode_view',
|
|
|
|
$this->getPodcast()->name,
|
|
|
|
$this->attributes['slug']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getGuid()
|
|
|
|
{
|
|
|
|
return $this->getLink();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPodcast()
|
|
|
|
{
|
|
|
|
$podcast_model = new PodcastModel();
|
|
|
|
|
|
|
|
return $podcast_model->find($this->attributes['podcast_id']);
|
|
|
|
}
|
2020-06-08 20:32:42 +00:00
|
|
|
}
|