diff options
| author | horus | 2020-02-24 00:52:12 +0100 |
|---|---|---|
| committer | horus | 2020-02-24 00:52:12 +0100 |
| commit | 38843f78bfbd27969df853377696dc8f8c71a921 (patch) | |
| tree | d40f35eda1c39e727c73a7037e20d463ef03aaf1 /app/AnimeScore.php | |
| parent | 2cd1589d6ae7095770e8c5dda10b138861d70501 (diff) | |
| download | senpai-38843f78bfbd27969df853377696dc8f8c71a921.tar.gz | |
Adds models for score tracking.
Diffstat (limited to 'app/AnimeScore.php')
| -rw-r--r-- | app/AnimeScore.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/app/AnimeScore.php b/app/AnimeScore.php new file mode 100644 index 0000000..9f150d0 --- /dev/null +++ b/app/AnimeScore.php @@ -0,0 +1,77 @@ +<?php + +namespace App; + +use Jikan\MyAnimeList\MalClient; + +class AnimeScore extends Anime { + + public $score; + public $scored_by; + public $rank; + public $popularity; + public $members; + public $favorites; + + public $watching; + public $completed; + public $onhold; + public $dropped; + public $plan_to_watch; + + public $score_1; + public $score_2; + public $score_3; + public $score_4; + public $score_5; + public $score_6; + public $score_7; + public $score_8; + public $score_9; + public $score_10; + + /** + * Eloquent ORM + */ + protected $table = 'stats'; + + public function __construct( $id ) { + $this->id = $id; + + parent::__construct($this->id); + + $jikan = new Malclient; + + $animeInfo = $this->getInfo(); + $this->score = $animeInfo->getScore(); + $this->scored_by = $animeInfo->getScoredBy(); + $this->rank = $animeInfo->getRank(); + $this->popularity = $animeInfo->getPopularity(); + $this->members = $animeInfo->getMembers(); + $this->favorites = $animeInfo->getFavorites(); + + $animeStats = $jikan->getAnimeStats( + (new \Jikan\Request\Anime\AnimeStatsRequest( $this->id )) + ); + + $this->watching = $animeStats->getWatching(); + $this->completed = $animeStats->getCompleted(); + $this->onhold = $animeStats->getOnHold(); + $this->dropped = $animeStats->getDropped(); + $this->plan_to_watch = $animeStats->getPlanToWatch(); + + $scores = $animeStats->getScores(); + + $this->score_1 = $scores[1]->getVotes(); + $this->score_2 = $scores[2]->getVotes(); + $this->score_3 = $scores[3]->getVotes(); + $this->score_4 = $scores[4]->getVotes(); + $this->score_5 = $scores[5]->getVotes(); + $this->score_6 = $scores[6]->getVotes(); + $this->score_7 = $scores[7]->getVotes(); + $this->score_8 = $scores[8]->getVotes(); + $this->score_9 = $scores[9]->getVotes(); + $this->score_10 = $scores[10]->getVotes(); + } + +} |
