From 9372059e1ec058f37a55a54a60cbeb59a226bde6 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 16 Jun 2017 13:04:51 +0100 Subject: [PATCH] Remove duplicate titleurl check now we are using better sluggable method --- .../Controllers/Admin/ArticlesController.php | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/Admin/ArticlesController.php b/app/Http/Controllers/Admin/ArticlesController.php index e10c68d2..e5d5085c 100644 --- a/app/Http/Controllers/Admin/ArticlesController.php +++ b/app/Http/Controllers/Admin/ArticlesController.php @@ -45,31 +45,19 @@ class ArticlesController extends Controller $published = '0'; } //if a `.md` is attached use that for the main content. - $content = null; //set default value if ($request->hasFile('article')) { $file = $request->file('article')->openFile(); $content = $file->fread($file->getSize()); } $main = $content ?? $request->input('main'); - try { - $article = Article::create( - [ - 'url' => $request->input('url'), - 'title' => $request->input('title'), - 'main' => $main, - 'published' => $published, - ] - ); - } catch (Exception $e) { - $msg = $e->getMessage(); - $unique = strpos($msg, '1062'); - if ($unique !== false) { - //We've checked for error 1062, i.e. duplicate titleurl - return redirect('/admin/blog/create')->withInput()->with('message', 'Duplicate title, please change'); - } - //this isn't the error you're looking for - throw $e; - } + $article = Article::create( + [ + 'url' => $request->input('url'), + 'title' => $request->input('title'), + 'main' => $main, + 'published' => $published, + ] + ); return redirect('/admin/blog'); }