2020-06-08 20:32:42 +00:00
|
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
|
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-12-07 20:13:46 +00:00
|
|
|
|
use App\Models\SoundbiteModel;
|
2020-06-08 20:32:42 +00:00
|
|
|
|
use CodeIgniter\Entity;
|
2020-10-22 17:41:59 +00:00
|
|
|
|
use CodeIgniter\I18n\Time;
|
2020-08-04 11:25:22 +00:00
|
|
|
|
use League\CommonMark\CommonMarkConverter;
|
2020-06-08 20:32:42 +00:00
|
|
|
|
|
|
|
|
|
class Episode extends Entity
|
|
|
|
|
{
|
2020-08-05 17:26:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var \App\Entities\Podcast
|
|
|
|
|
*/
|
|
|
|
|
protected $podcast;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $link;
|
|
|
|
|
|
|
|
|
|
/**
|
2020-09-08 11:45:17 +00:00
|
|
|
|
* @var \App\Entities\Image
|
2020-08-05 17:26:04 +00:00
|
|
|
|
*/
|
|
|
|
|
protected $image;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \CodeIgniter\Files\File
|
|
|
|
|
*/
|
|
|
|
|
protected $enclosure;
|
|
|
|
|
|
2020-11-24 20:18:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var \CodeIgniter\Files\File
|
|
|
|
|
*/
|
|
|
|
|
protected $transcript;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \CodeIgniter\Files\File
|
|
|
|
|
*/
|
|
|
|
|
protected $chapters;
|
|
|
|
|
|
2020-08-05 17:26:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $enclosure_media_path;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $enclosure_url;
|
|
|
|
|
|
2020-10-26 16:13:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $enclosure_web_url;
|
|
|
|
|
|
2020-11-04 17:03:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $enclosure_opengraph_url;
|
|
|
|
|
|
2020-11-24 20:18:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $transcript_url;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $chapters_url;
|
|
|
|
|
|
2020-12-07 20:13:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var \App\Entities\Soundbite[]
|
|
|
|
|
*/
|
|
|
|
|
protected $soundbites;
|
|
|
|
|
|
2020-08-05 17:26:04 +00:00
|
|
|
|
/**
|
2020-10-29 15:45:19 +00:00
|
|
|
|
* Holds text only description, striped of any markdown or html special characters
|
|
|
|
|
*
|
2020-08-05 17:26:04 +00:00
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2020-10-29 15:45:19 +00:00
|
|
|
|
protected $description;
|
2020-06-26 14:34:52 +00:00
|
|
|
|
|
2020-10-22 17:41:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* @var boolean
|
|
|
|
|
*/
|
|
|
|
|
protected $is_published;
|
|
|
|
|
|
2020-08-14 18:27:57 +00:00
|
|
|
|
protected $dates = [
|
|
|
|
|
'published_at',
|
|
|
|
|
'created_at',
|
|
|
|
|
'updated_at',
|
|
|
|
|
'deleted_at',
|
|
|
|
|
];
|
|
|
|
|
|
2020-06-08 20:32:42 +00:00
|
|
|
|
protected $casts = [
|
2020-12-07 20:13:46 +00:00
|
|
|
|
'id' => 'integer',
|
2020-08-21 08:41:09 +00:00
|
|
|
|
'guid' => 'string',
|
2020-06-08 20:32:42 +00:00
|
|
|
|
'slug' => 'string',
|
|
|
|
|
'title' => 'string',
|
2020-06-26 14:34:52 +00:00
|
|
|
|
'enclosure_uri' => 'string',
|
2020-09-04 09:09:26 +00:00
|
|
|
|
'enclosure_duration' => 'integer',
|
|
|
|
|
'enclosure_mimetype' => 'string',
|
|
|
|
|
'enclosure_filesize' => 'integer',
|
2020-10-06 15:39:27 +00:00
|
|
|
|
'enclosure_headersize' => 'integer',
|
2020-10-29 15:45:19 +00:00
|
|
|
|
'description_markdown' => 'string',
|
|
|
|
|
'description_html' => 'string',
|
2020-06-30 18:17:41 +02:00
|
|
|
|
'image_uri' => '?string',
|
2020-11-24 20:18:08 +00:00
|
|
|
|
'transcript_uri' => '?string',
|
|
|
|
|
'chapters_uri' => '?string',
|
2020-10-02 15:38:16 +00:00
|
|
|
|
'parental_advisory' => '?string',
|
2020-08-21 08:41:09 +00:00
|
|
|
|
'number' => '?integer',
|
2020-06-08 20:32:42 +00:00
|
|
|
|
'season_number' => '?integer',
|
|
|
|
|
'type' => 'string',
|
2020-10-29 15:45:19 +00:00
|
|
|
|
'is_blocked' => 'boolean',
|
2020-08-14 18:27:57 +00:00
|
|
|
|
'created_by' => 'integer',
|
|
|
|
|
'updated_by' => 'integer',
|
2020-06-08 20:32:42 +00:00
|
|
|
|
];
|
2020-06-26 14:34:52 +00:00
|
|
|
|
|
2020-08-21 08:41:09 +00:00
|
|
|
|
/**
|
|
|
|
|
* Saves an episode image
|
|
|
|
|
*
|
|
|
|
|
* @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $image
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function setImage($image)
|
2020-06-30 18:17:41 +02:00
|
|
|
|
{
|
2020-08-21 08:41:09 +00:00
|
|
|
|
if (
|
|
|
|
|
!empty($image) &&
|
|
|
|
|
(!($image instanceof \CodeIgniter\HTTP\Files\UploadedFile) ||
|
|
|
|
|
$image->isValid())
|
|
|
|
|
) {
|
2020-09-08 11:45:17 +00:00
|
|
|
|
helper('media');
|
|
|
|
|
|
2020-06-30 18:17:41 +02:00
|
|
|
|
// check whether the user has inputted an image and store it
|
|
|
|
|
$this->attributes['image_uri'] = save_podcast_media(
|
|
|
|
|
$image,
|
|
|
|
|
$this->getPodcast()->name,
|
|
|
|
|
$this->attributes['slug']
|
|
|
|
|
);
|
2020-09-08 11:45:17 +00:00
|
|
|
|
|
|
|
|
|
$this->image = new \App\Entities\Image(
|
|
|
|
|
$this->attributes['image_uri']
|
|
|
|
|
);
|
|
|
|
|
$this->image->saveSizes();
|
2020-06-30 18:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-08 11:45:17 +00:00
|
|
|
|
public function getImage(): \App\Entities\Image
|
2020-06-26 14:34:52 +00:00
|
|
|
|
{
|
2020-06-30 18:17:41 +02:00
|
|
|
|
if ($image_uri = $this->attributes['image_uri']) {
|
2020-09-08 11:45:17 +00:00
|
|
|
|
return new \App\Entities\Image($image_uri);
|
2020-06-30 18:17:41 +02:00
|
|
|
|
}
|
2020-09-08 11:45:17 +00:00
|
|
|
|
return $this->getPodcast()->image;
|
2020-06-30 18:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 08:41:09 +00:00
|
|
|
|
/**
|
|
|
|
|
* Saves an enclosure
|
|
|
|
|
*
|
|
|
|
|
* @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $enclosure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function setEnclosure($enclosure = null)
|
|
|
|
|
{
|
|
|
|
|
if (
|
|
|
|
|
!empty($enclosure) &&
|
|
|
|
|
(!($enclosure instanceof \CodeIgniter\HTTP\Files\UploadedFile) ||
|
|
|
|
|
$enclosure->isValid())
|
|
|
|
|
) {
|
2020-09-04 09:09:26 +00:00
|
|
|
|
helper(['media', 'id3']);
|
|
|
|
|
|
|
|
|
|
$enclosure_metadata = get_file_tags($enclosure);
|
2020-06-30 18:17:41 +02:00
|
|
|
|
|
|
|
|
|
$this->attributes['enclosure_uri'] = save_podcast_media(
|
|
|
|
|
$enclosure,
|
|
|
|
|
$this->getPodcast()->name,
|
|
|
|
|
$this->attributes['slug']
|
|
|
|
|
);
|
2020-09-04 09:09:26 +00:00
|
|
|
|
$this->attributes['enclosure_duration'] = round(
|
|
|
|
|
$enclosure_metadata['playtime_seconds']
|
|
|
|
|
);
|
|
|
|
|
$this->attributes['enclosure_mimetype'] =
|
|
|
|
|
$enclosure_metadata['mime_type'];
|
|
|
|
|
$this->attributes['enclosure_filesize'] =
|
|
|
|
|
$enclosure_metadata['filesize'];
|
2020-10-06 15:39:27 +00:00
|
|
|
|
$this->attributes['enclosure_headersize'] =
|
|
|
|
|
$enclosure_metadata['avdataoffset'];
|
2020-06-30 18:17:41 +02:00
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 20:18:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* Saves an episode transcript
|
|
|
|
|
*
|
|
|
|
|
* @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $transcript
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function setTranscript($transcript)
|
|
|
|
|
{
|
|
|
|
|
if (
|
|
|
|
|
!empty($transcript) &&
|
|
|
|
|
(!($transcript instanceof \CodeIgniter\HTTP\Files\UploadedFile) ||
|
|
|
|
|
$transcript->isValid())
|
|
|
|
|
) {
|
|
|
|
|
helper('media');
|
|
|
|
|
|
|
|
|
|
$this->attributes['transcript_uri'] = save_podcast_media(
|
|
|
|
|
$transcript,
|
|
|
|
|
$this->getPodcast()->name,
|
|
|
|
|
$this->attributes['slug'] . '-transcript'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Saves an episode chapters
|
|
|
|
|
*
|
|
|
|
|
* @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $chapters
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function setChapters($chapters)
|
|
|
|
|
{
|
|
|
|
|
if (
|
|
|
|
|
!empty($chapters) &&
|
|
|
|
|
(!($chapters instanceof \CodeIgniter\HTTP\Files\UploadedFile) ||
|
|
|
|
|
$chapters->isValid())
|
|
|
|
|
) {
|
|
|
|
|
helper('media');
|
|
|
|
|
|
|
|
|
|
$this->attributes['chapters_uri'] = save_podcast_media(
|
|
|
|
|
$chapters,
|
|
|
|
|
$this->getPodcast()->name,
|
|
|
|
|
$this->attributes['slug'] . '-chapters'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-30 18:17:41 +02:00
|
|
|
|
public function getEnclosure()
|
|
|
|
|
{
|
|
|
|
|
return new \CodeIgniter\Files\File($this->getEnclosureMediaPath());
|
2020-06-26 14:34:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 20:18:08 +00:00
|
|
|
|
public function getTranscript()
|
|
|
|
|
{
|
|
|
|
|
return $this->attributes['transcript_uri']
|
|
|
|
|
? new \CodeIgniter\Files\File($this->getTranscriptMediaPath())
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getChapters()
|
|
|
|
|
{
|
|
|
|
|
return $this->attributes['chapters_uri']
|
|
|
|
|
? new \CodeIgniter\Files\File($this->getChaptersMediaPath())
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
|
public function getEnclosureMediaPath()
|
|
|
|
|
{
|
2020-06-30 18:17:41 +02:00
|
|
|
|
helper('media');
|
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
|
return media_path($this->attributes['enclosure_uri']);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 20:18:08 +00:00
|
|
|
|
public function getTranscriptMediaPath()
|
|
|
|
|
{
|
|
|
|
|
helper('media');
|
|
|
|
|
|
|
|
|
|
return $this->attributes['transcript_uri']
|
|
|
|
|
? media_path($this->attributes['transcript_uri'])
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getChaptersMediaPath()
|
|
|
|
|
{
|
|
|
|
|
helper('media');
|
|
|
|
|
|
|
|
|
|
return $this->attributes['chapters_uri']
|
|
|
|
|
? media_path($this->attributes['chapters_uri'])
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
|
public function getEnclosureUrl()
|
|
|
|
|
{
|
2020-10-29 17:27:16 +01:00
|
|
|
|
helper('analytics');
|
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
|
return base_url(
|
|
|
|
|
route_to(
|
|
|
|
|
'analytics_hit',
|
2020-10-29 17:27:16 +01:00
|
|
|
|
base64_url_encode(
|
|
|
|
|
pack(
|
|
|
|
|
'I*',
|
|
|
|
|
$this->attributes['podcast_id'],
|
|
|
|
|
$this->attributes['id'],
|
|
|
|
|
// bytes_threshold: number of bytes that must be downloaded for an episode to be counted in download analytics
|
|
|
|
|
// - if file is shorter than 60sec, then it's enclosure_filesize
|
|
|
|
|
// - if file is longer than 60 seconds then it's enclosure_headersize + 60 seconds
|
|
|
|
|
$this->attributes['enclosure_duration'] <= 60
|
|
|
|
|
? $this->attributes['enclosure_filesize']
|
|
|
|
|
: $this->attributes['enclosure_headersize'] +
|
|
|
|
|
floor(
|
|
|
|
|
(($this->attributes['enclosure_filesize'] -
|
|
|
|
|
$this->attributes[
|
|
|
|
|
'enclosure_headersize'
|
|
|
|
|
]) /
|
|
|
|
|
$this->attributes[
|
|
|
|
|
'enclosure_duration'
|
|
|
|
|
]) *
|
|
|
|
|
60
|
|
|
|
|
),
|
|
|
|
|
$this->attributes['enclosure_filesize'],
|
|
|
|
|
$this->attributes['enclosure_duration'],
|
|
|
|
|
strtotime($this->attributes['published_at'])
|
|
|
|
|
)
|
|
|
|
|
),
|
2020-06-26 14:34:52 +00:00
|
|
|
|
$this->attributes['enclosure_uri']
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-26 17:26:41 +00:00
|
|
|
|
public function getEnclosureWebUrl()
|
2020-10-26 16:13:43 +00:00
|
|
|
|
{
|
|
|
|
|
return $this->getEnclosureUrl() . '?_from=-+Website+-';
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 17:03:20 +00:00
|
|
|
|
public function getEnclosureOpengraphUrl()
|
|
|
|
|
{
|
|
|
|
|
return $this->getEnclosureUrl() . '?_from=-+Open+Graph+-';
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 20:18:08 +00:00
|
|
|
|
public function getTranscriptUrl()
|
|
|
|
|
{
|
|
|
|
|
return $this->attributes['transcript_uri']
|
|
|
|
|
? base_url($this->getTranscriptMediaPath())
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getChaptersUrl()
|
|
|
|
|
{
|
|
|
|
|
return $this->attributes['chapters_uri']
|
|
|
|
|
? base_url($this->getChaptersMediaPath())
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-07 20:13:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the episode’s soundbites
|
|
|
|
|
*
|
|
|
|
|
* @return \App\Entities\Episode[]
|
|
|
|
|
*/
|
|
|
|
|
public function getSoundbites()
|
|
|
|
|
{
|
|
|
|
|
if (empty($this->id)) {
|
|
|
|
|
throw new \RuntimeException(
|
|
|
|
|
'Episode must be created before getting soundbites.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($this->soundbites)) {
|
|
|
|
|
$this->soundbites = (new SoundbiteModel())->getEpisodeSoundbites(
|
|
|
|
|
$this->getPodcast()->id,
|
|
|
|
|
$this->id
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->soundbites;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
|
public function getLink()
|
|
|
|
|
{
|
|
|
|
|
return base_url(
|
|
|
|
|
route_to(
|
2020-07-10 12:20:25 +00:00
|
|
|
|
'episode',
|
2020-06-26 14:34:52 +00:00
|
|
|
|
$this->getPodcast()->name,
|
|
|
|
|
$this->attributes['slug']
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 15:57:01 +00:00
|
|
|
|
public function setGuid(string $guid)
|
2020-06-26 14:34:52 +00:00
|
|
|
|
{
|
2020-08-21 08:41:09 +00:00
|
|
|
|
return $this->attributes['guid'] = empty($guid)
|
|
|
|
|
? $this->getLink()
|
|
|
|
|
: $guid;
|
2020-06-26 14:34:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPodcast()
|
|
|
|
|
{
|
2020-09-04 09:09:26 +00:00
|
|
|
|
return (new PodcastModel())->getPodcastById(
|
|
|
|
|
$this->attributes['podcast_id']
|
|
|
|
|
);
|
2020-06-26 14:34:52 +00:00
|
|
|
|
}
|
2020-07-27 09:35:34 +00:00
|
|
|
|
|
2020-10-29 15:45:19 +00:00
|
|
|
|
public function setDescriptionMarkdown(string $descriptionMarkdown)
|
2020-07-27 09:35:34 +00:00
|
|
|
|
{
|
2020-08-04 11:25:22 +00:00
|
|
|
|
$converter = new CommonMarkConverter([
|
|
|
|
|
'html_input' => 'strip',
|
|
|
|
|
'allow_unsafe_links' => false,
|
|
|
|
|
]);
|
2020-07-27 09:35:34 +00:00
|
|
|
|
|
2020-10-29 15:45:19 +00:00
|
|
|
|
$this->attributes['description_markdown'] = $descriptionMarkdown;
|
|
|
|
|
$this->attributes['description_html'] = $converter->convertToHtml(
|
|
|
|
|
$descriptionMarkdown
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDescriptionHtml()
|
|
|
|
|
{
|
2020-07-27 09:35:34 +00:00
|
|
|
|
if (
|
2020-10-29 15:45:19 +00:00
|
|
|
|
$descriptionFooter = $this->getPodcast()
|
|
|
|
|
->episode_description_footer_html
|
2020-07-27 09:35:34 +00:00
|
|
|
|
) {
|
2020-10-29 15:45:19 +00:00
|
|
|
|
return $this->attributes['description_html'] .
|
2020-07-28 15:57:48 +00:00
|
|
|
|
'<footer>' .
|
2020-10-29 15:45:19 +00:00
|
|
|
|
$descriptionFooter .
|
2020-07-28 15:57:48 +00:00
|
|
|
|
'</footer>';
|
2020-07-27 09:35:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 15:45:19 +00:00
|
|
|
|
return $this->attributes['description_html'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDescription()
|
|
|
|
|
{
|
|
|
|
|
if ($this->description) {
|
|
|
|
|
return $this->description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return trim(
|
|
|
|
|
preg_replace(
|
|
|
|
|
'/\s+/',
|
|
|
|
|
' ',
|
|
|
|
|
strip_tags($this->attributes['description_html'])
|
|
|
|
|
)
|
|
|
|
|
);
|
2020-07-27 09:35:34 +00:00
|
|
|
|
}
|
2020-08-14 18:27:57 +00:00
|
|
|
|
|
|
|
|
|
public function setCreatedBy(\App\Entities\User $user)
|
|
|
|
|
{
|
|
|
|
|
$this->attributes['created_by'] = $user->id;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setUpdatedBy(\App\Entities\User $user)
|
|
|
|
|
{
|
|
|
|
|
$this->attributes['updated_by'] = $user->id;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2020-10-22 17:41:59 +00:00
|
|
|
|
|
|
|
|
|
public function getIsPublished()
|
|
|
|
|
{
|
|
|
|
|
if ($this->is_published) {
|
|
|
|
|
return $this->is_published;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
helper('date');
|
|
|
|
|
|
|
|
|
|
$this->is_published = $this->published_at->isBefore(Time::now());
|
|
|
|
|
|
|
|
|
|
return $this->is_published;
|
|
|
|
|
}
|
2020-06-08 20:32:42 +00:00
|
|
|
|
}
|