From 416ce7ac6aa09437c9a335e7ed75b861b8f617e9 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 10 Sep 2015 12:56:33 +0100 Subject: [PATCH] Merge rPF9c520e71a551: T357: Handle malformed genres gracefully. --- app/Console/Commands/ImportMLPMA.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/ImportMLPMA.php b/app/Console/Commands/ImportMLPMA.php index 1d7d559d..086d343c 100644 --- a/app/Console/Commands/ImportMLPMA.php +++ b/app/Console/Commands/ImportMLPMA.php @@ -208,9 +208,10 @@ class ImportMLPMA extends Command // Determine the genre. //========================================================================================================== $genreName = $parsedTags['genre']; + $genreSlug = Str::slug($genreName); $this->info('Genre: ' . $genreName); - if ($genreName) { + if ($genreName && $genreSlug !== '') { $genre = Genre::where('name', '=', $genreName)->first(); if ($genre) { $genreId = $genre->id; @@ -218,7 +219,7 @@ class ImportMLPMA extends Command } else { $genre = new Genre(); $genre->name = $genreName; - $genre->slug = Str::slug($genreName); + $genre->slug = $genreSlug; $genre->save(); $genreId = $genre->id; $this->comment('Created a new genre!');