FEATURE: prevent searching empty string.

This commit adds exception handling for serching empty string
This commit is contained in:
Michal Kváček
2016-03-15 14:00:19 +01:00
parent c4e65e18c4
commit b3da43921b
2 changed files with 20 additions and 2 deletions
+7 -1
View File
@@ -11,12 +11,18 @@ class Search extends Controller
{
public function getSearch()
{
$results = [];
$term = Input::get('search');
if (!is_null($term)) {
try {
$results = $this->performSearch($term);
} catch (InvalidArgumentException $e) {
// user entered empty string (or something like empty string)
return redirect()
->route('search')
->with('error', $e->getMessage());
}
}
return view('admin.search.page', ['search' => $term, 'results' => $results]);
@@ -8,6 +8,18 @@
<h2>@lang('search.pageTitle')</h2>
</div>
@if (session('success'))
<div data-alert class="callout success">
<strong>{{ session('success') }}</strong>
</div>
@endif
@if (session('error'))
<div data-alert class="callout alert">
<strong>{{ session('error') }}</strong>
</div>
@endif
@if ($search)
<div class="row">
<div class="column large-8">