Remove duplicate titleurl check now we are using better sluggable method
This commit is contained in:
parent
522f06162e
commit
9372059e1e
1 changed files with 8 additions and 20 deletions
|
@ -45,13 +45,11 @@ class ArticlesController extends Controller
|
||||||
$published = '0';
|
$published = '0';
|
||||||
}
|
}
|
||||||
//if a `.md` is attached use that for the main content.
|
//if a `.md` is attached use that for the main content.
|
||||||
$content = null; //set default value
|
|
||||||
if ($request->hasFile('article')) {
|
if ($request->hasFile('article')) {
|
||||||
$file = $request->file('article')->openFile();
|
$file = $request->file('article')->openFile();
|
||||||
$content = $file->fread($file->getSize());
|
$content = $file->fread($file->getSize());
|
||||||
}
|
}
|
||||||
$main = $content ?? $request->input('main');
|
$main = $content ?? $request->input('main');
|
||||||
try {
|
|
||||||
$article = Article::create(
|
$article = Article::create(
|
||||||
[
|
[
|
||||||
'url' => $request->input('url'),
|
'url' => $request->input('url'),
|
||||||
|
@ -60,16 +58,6 @@ class ArticlesController extends Controller
|
||||||
'published' => $published,
|
'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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect('/admin/blog');
|
return redirect('/admin/blog');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue