Разрешить 4 буквы

This commit is contained in:
Alexander Yakovlev 2021-07-30 21:36:31 +07:00
parent 2e68a2e624
commit 60ae6b344a
Signed by: oreolek
GPG key ID: 8D24103F5EE2A6C0

View file

@ -26,14 +26,14 @@ class SearchController extends Controller
$error = 'В названии разрешены только буквы.'; $error = 'В названии разрешены только буквы.';
} }
} }
if (!empty($term) && mb_strlen($term) > 4) { if (!empty($term) && mb_strlen($term) >= 4) {
$term = mb_strtolower($term); $term = mb_strtolower($term);
$options = Game::where(DB::raw('LOWER(title)'), 'LIKE', '%'.$term.'%')->get(); $options = Game::where(DB::raw('LOWER(title)'), 'LIKE', '%'.$term.'%')->get();
if ($options->count() === 1) { if ($options->count() === 1) {
$page = new Wikipage($options[0]); $page = new Wikipage($options[0]);
$response = $page->getContent(); $response = $page->getContent();
} }
} elseif (!empty($term) && mb_strlen($term) <= 4) { } elseif (!empty($term) && mb_strlen($term) < 4) {
$error = 'Слишком короткая строка поиска, нужно не менее 4 букв.'; $error = 'Слишком короткая строка поиска, нужно не менее 4 букв.';
} }
return view('welcome', [ return view('welcome', [