diff --git a/.gitignore b/.gitignore index 66aeb7b..3cc8dd3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ /public/storage /storage/*.key /storage/pail -/storage/dbbackups /vendor Homestead.json Homestead.yaml diff --git a/app/Console/Commands/DjangoImport.php b/app/Console/Commands/DjangoImport.php deleted file mode 100644 index af1be67..0000000 --- a/app/Console/Commands/DjangoImport.php +++ /dev/null @@ -1,226 +0,0 @@ -wipeTables(); - - $this->importMovies(); - $this->importMovielists(); - $this->importMovieListMovies(); - $this->importSchedules(); - $this->importShowings(); - } - - private function wipeTables() - { - $this->info('Truncating tables...'); - - DB::statement('SET FOREIGN_KEY_CHECKS=0;'); - DB::table('movie_movie_list')->truncate(); - DB::table('movies')->truncate(); - DB::table('movie_lists')->truncate(); - DB::table('schedules')->truncate(); - DB::table('showings')->truncate(); - DB::statement('SET FOREIGN_KEY_CHECKS=1;'); - } - - private function importMovies($fileName = 'moviemanager_movies.csv'): void - { - $this->info('Importing movies...'); - - $file = fopen(storage_path($this->csvPath.$fileName), 'r'); - if (! $file) { - $this->error('File not found: '.$fileName); - - return; - } - - // Skip the header row - fgetcsv($file); - - while (($row = fgetcsv($file)) !== false) { - Movie::forceCreate([ - 'id' => $row[0], - 'title' => $row[1], - 'imdb_id' => $row[2], - 'year' => $row[3], - 'director' => $row[4], - 'actors' => $row[5], - 'plot' => $row[6], - 'genre' => $row[7], - 'mpaa_rating' => $row[8], - 'critic_scores' => $this->parsePythonList($row[9]), - 'poster' => $row[10], - 'added_by' => $row[11], - ]); - } - - fclose($file); - - } - - /** - * Convert a Python-style list string (single-quoted) to a PHP array. - * - * @return array> - */ - private function parsePythonList(string $value): array - { - if (empty($value) || $value === '[]') { - return []; - } - - $json = str_replace("'", '"', $value); - if (str_starts_with($json, '{')) { - // Fixes incorrect key for Source in some older data - $json = str_replace('Score', 'Source', $json); - $json = '['.$json.']'; - - } - $decoded = json_decode($json, true); - - if (is_array($decoded)) { - return $decoded; - } elseif (is_string($decoded)) { - return [$decoded]; - } - - return []; - } - - private function importMovielists($fileName = 'moviemanager_movielist.csv'): void - { - $this->info('Importing Movie Lists...'); - - $file = fopen(storage_path($this->csvPath.$fileName), 'r'); - if (! $file) { - $this->error('File not found: '.$fileName); - - return; - } - - // Skip the header row - fgetcsv($file); - - while (($row = fgetcsv($file)) !== false) { - MovieList::create([ - 'name' => $row[1], - 'is_public' => $row[2] === 't' ? true : false, - 'slug' => Str::slug($row[1]), - 'owner' => $row[3], - ]); - } - - fclose($file); - } - - private function importMovieListMovies($fileName = 'moviemanager_movielist_movies.csv'): void - { - $this->info('Importing movie_list_movies...'); - $file = fopen(storage_path($this->csvPath.$fileName), 'r'); - if (! $file) { - $this->error('File not found: '.$fileName); - - return; - } - - // Skip the header row - fgetcsv($file); - - while (($row = fgetcsv($file)) !== false) { - $movieList = MovieList::find($row[1]); - $movie = Movie::find($row[2]); - - if ($movieList && $movie) { - $movieList->movies()->attach($movie); - } else { - $this->error('Movie or MovieList not found. Movie ID: '.$row[2].', MovieList ID: '.$row[1]); - } - } - - fclose($file); - } - - private function importSchedules($fileName = 'moviemanager_schedule.csv'): void - { - $this->info('Importing schedules...'); - $file = fopen(storage_path($this->csvPath.$fileName), 'r'); - if (! $file) { - $this->error('File not found: '.$fileName); - - return; - } - - // Skip the header row - fgetcsv($file); - - while (($row = fgetcsv($file)) !== false) { - Schedule::create([ - 'name' => $row[1], - 'is_public' => $row[2] === 't' ? true : false, - 'slug' => $row[3], - 'owner' => $row[4], - ]); - } - - fclose($file); - } - - private function importShowings($fileName = 'moviemanager_showing.csv'): void - { - $this->info('Importing showings...'); - $file = fopen(storage_path($this->csvPath.$fileName), 'r'); - if (! $file) { - $this->error('File not found: '.$fileName); - - return; - } - - // Skip the header row - fgetcsv($file); - - while (($row = fgetcsv($file)) !== false) { - Showing::create([ - 'is_public' => $row[1] === 't' ? true : false, - 'showtime' => Carbon::parse($row[2]), - 'movie_id' => $row[3], - 'owner_id' => $row[4], - 'schedule_id' => $row[5], - ]); - } - - fclose($file); - } -} diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php deleted file mode 100644 index 14614f2..0000000 --- a/app/Models/Schedule.php +++ /dev/null @@ -1,15 +0,0 @@ -id(); - $table->string('name'); - $table->boolean('is_public')->default(false); - $table->string('slug'); - $table->foreignId('owner')->constrained('users')->cascadeOnDelete(); - $table->softDeletes(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('schedules'); - } -}; diff --git a/database/migrations/2026_04_20_233347_create_showings_table.php b/database/migrations/2026_04_20_233347_create_showings_table.php deleted file mode 100644 index 3fe8dc9..0000000 --- a/database/migrations/2026_04_20_233347_create_showings_table.php +++ /dev/null @@ -1,32 +0,0 @@ -id(); - $table->dateTime('showtime'); - $table->boolean('is_public')->default(false); - $table->foreignId('movie_id')->constrained('movies')->cascadeOnDelete(); - $table->foreignId('owner_id')->constrained('users')->cascadeOnDelete(); - $table->foreignId('schedule_id')->constrained('schedules')->cascadeOnDelete(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('showings'); - } -};