From 0c521f4907ee74cda8d4b6810a5ccb21c175f857 Mon Sep 17 00:00:00 2001 From: horus Date: Thu, 17 Sep 2020 23:37:00 +0200 Subject: add season to anime model --- app/Anime.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'app/Anime.php') diff --git a/app/Anime.php b/app/Anime.php index 08c0dd1..2c2e57d 100644 --- a/app/Anime.php +++ b/app/Anime.php @@ -26,7 +26,9 @@ class Anime extends Model { 'anime_type', 'broadcasted', 'episodes', - 'airing_status' + 'airing_status', + 'season_year', + 'season_name' ]; public function __construct() { @@ -73,6 +75,18 @@ class Anime extends Model { $this->episodes = $animeInfo->getEpisodes(); $this->airing_status = getAiringStatusCode($animeInfo->getStatus()); + + if ( is_null($animeInfo->getPremiered()) ) { + if ( env('ANIME_NOT_YET_AIRED') != $this->airing_status ) { + $tmp_date = getSeasonFromDate( $animeInfo->getAired()->getFrom() ); + + $this->season_name = $tmp_date["name"]; + $this->season_year = $tmp_date["year"]; + } + } else { + $this->season_name = explode(" ", $this->getPremiered())[0]; + $this->season_year = explode(" ", $this->getPremiered())[1]; + } } public function getStats() { -- cgit v1.2.3