From 5dda561d73c9a5698386d643d56a142aa4bbdeec Mon Sep 17 00:00:00 2001 From: horus Date: Thu, 5 Mar 2020 16:02:10 +0100 Subject: Committing intermediate state. --- app/Http/Controllers/IndexController.php | 54 +++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'app/Http/Controllers/IndexController.php') diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index e254c50..11e587f 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -6,7 +6,9 @@ use Illuminate\Http\Request; use App\Libraries\AnimeSchedule; use App\Libraries\AnimeSeason; +use App\Anime; use App\AnimeStats; +use App\MALUser; class IndexController extends Controller { /** @@ -36,11 +38,61 @@ class IndexController extends Controller { } public function test($param = null) { - $season = new AnimeSeason(); + echo "
";
+		#$season = new AnimeSeason();
 		#$stats = new AnimeScore( 21 );
 
 		#var_dump($stats);
 		#echo "
";
 		#var_dump($season);
+		#
+		#$test = new AnimeSchedule("", false);
+
+		#var_dump( Anime::where('mal_id', 38408)->with('user')->get() );
+		#var_dump( MALUser::where('username', 'll-')->with('anime')->toSql() );
+		#var_dump( MALUser::find(10)->anime()->get() );
+		$test = MALUser::where('username', 'll-')->get()->first();
+		#$test = MALUser::where('username', 'll-')->with('IsWatching')->first();
+		#var_dump($test);
+		#var_dump( MALUser::where('username', 'll-')->with('IsWatching')->firstOrFail() );
+		#var_dump( $test );
+		#var_dump( MALUser::with('IsWatching')->firstOrFail() );
+		echo "
";
+		foreach( $test->IsWatching as $anime ) {
+			echo $anime->title_pref . "\n";
+		}
+		#var_dump($test->IsWatching);
+
+	}
+
+	public function saveWatchingAnime() {
+		$test = MALUser::where('username', 'll-')->get()->first();
+
+		$is_watching= $test->getIsWatching();
+		foreach( $is_watching as $anime_details ) {
+			$anime = Anime::where('mal_id', $anime_details["mal_id"])->get()->first();
+			#$anime->fill( $is_watching["mal_id"] );
+			$test->IsWatching()->save( $anime, $anime_details );
+			#var_dump($anime);
+			#exit;
+		}
+		#echo $test->test();
+		echo "OK";
+	}
+
+	public function createUser( $username ) {
+		$user = MALUser::where('username', $username)->get()->first();
+		var_dump( $user );
+
+		if ( is_null($user) ) {
+			$user = new MALUser();
+			$user->set( $username );
+
+			var_dump( $user );
+
+			$user->save();
+		}
+
+		echo $user->get();
 	}
 }
-- 
cgit v1.2.3