summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Anime.php1
-rw-r--r--app/Libraries/Background.php5
-rw-r--r--database/migrations/2020_09_19_214845_add_duration_to_anime.php32
3 files changed, 37 insertions, 1 deletions
diff --git a/app/Anime.php b/app/Anime.php
index 2c2e57d..81fdee3 100644
--- a/app/Anime.php
+++ b/app/Anime.php
@@ -158,6 +158,7 @@ class Anime extends Model {
}
description
hashtag
+ duration
}
}
';
diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php
index fbdaa1f..2d63a3e 100644
--- a/app/Libraries/Background.php
+++ b/app/Libraries/Background.php
@@ -210,6 +210,9 @@ class Background {
if ( ! is_null( $enhancement->title->userPreferred ) ) {
$update["title_pref"] = $enhancement->title->userPreferred;
}
+ if ( ! is_null( $enhancement->duration ) ) {
+ $update["duration"] = $enhancement->duration;
+ }
#echo "Updating " . $anime->title_pref . " (" . $anime->mal_id . ")\n";
DB::table('anime')
@@ -219,7 +222,7 @@ class Background {
public function saveEnhancementForAll() {
#$anime_all = Anime::where('airing_status', env('ANIME_IS_AIRING'))->where('synopsis', '')->get();
- $anime_all = Anime::where('synopsis', '')->get();
+ $anime_all = Anime::where('synopsis', '')->orWhereNull('duration')->get();
foreach( $anime_all as $anime ) {
$this->addEnhancementToAnime($anime);
sleep(1);
diff --git a/database/migrations/2020_09_19_214845_add_duration_to_anime.php b/database/migrations/2020_09_19_214845_add_duration_to_anime.php
new file mode 100644
index 0000000..b9a1f7f
--- /dev/null
+++ b/database/migrations/2020_09_19_214845_add_duration_to_anime.php
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddDurationToAnime extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('anime', function (Blueprint $table) {
+ $table->integer('duration')->nullable()->default(null);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('anime', function (Blueprint $table) {
+ $table->dropColumn('duration');
+ });
+ }
+}