I've got an problem.
How could I validate an search function? Like if it fails to find the user, it'll display an error message. I've tried several things, but none of them works. Here's my form:
(search/search.blade.php)
<form id="custom-search-form" class="form-search form-horizontal pull-right" action="{{ URL::action('CharactersController@search') }}" method="get">
<div class="input-append span9">
<input type="text" class="search-query" name="character" placeholder="Character/guild name">
<button type="submit" class="btn"><i class="icon-search"></i></button>
</div>
I've tried to do something like: @if ($searchResult->count())
- it works, but it displays every time I enter the search site.
Here's my controller's acction:
public function search()
{
$name = Input::get('character');
$searchResult = Player::where('name', '=', $name)->get();
return View::make('search.search')
->with('name', $name)
->with('searchResult', $searchResult);
}