FEATURE: prevent searching empty string.
This commit adds exception handling for serching empty string
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user