summaryrefslogtreecommitdiff
path: root/app/Anime.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Anime.php')
-rw-r--r--app/Anime.php49
1 files changed, 37 insertions, 12 deletions
diff --git a/app/Anime.php b/app/Anime.php
index b13f785..1e8fb95 100644
--- a/app/Anime.php
+++ b/app/Anime.php
@@ -1,30 +1,55 @@
<?php
namespace App;
+use Illuminate\Database\Eloquent\Model;
-class Anime {
+use Jikan\MyAnimeList\MalClient;
+
+class Anime extends Model {
public $id;
+ public $url;
+ public $image_url;
+
public $title_eng;
public $title_rom;
public $title_nat;
public $title_pref;
- public $airing_at;
- public $time_until_airing;
- public $episode;
- public $duration;
+ public $type;
- public $episodes_complete;
- public $episodes_watched;
- public $score_user;
- public $score;
+ private $animeInfo;
- public $rank;
- public $popularity;
+ /**
+ * Eloquent ORM
+ */
+ protected $table = 'anime';
- public function __construct( $id ) {
+ public function __construct( $id, $parse_info = true ) {
$this->id = $id;
+
+ if ( $parse_info ) {
+ $jikan = new Malclient;
+
+ $this->animeInfo = $jikan->getAnime(
+ (new \Jikan\Request\Anime\AnimeRequest( $this->id ))
+ );
+
+ $this->url = $this->animeInfo->GetUrl();
+ $this->image_url = $this->animeInfo->getImageUrl();
+
+ $this->title_eng = $this->animeInfo->getTitleEnglish();
+ $this->title_rom = $this->animeInfo->getTitle();
+ $this->title_nat = $this->animeInfo->getTitleJapanese();
+ $this->title_pref = $this->animeInfo->getTitle();
+
+ $this->type = $this->animeInfo->getType();
+ }
}
+
+ protected function getInfo() {
+ return $this->animeInfo;
+ }
+
}