我有一个搜索表格和功能,全部完成。只是问一下,是否可以在 Eloquent 中执行如下查询:
SELECT * FROM players WHERE name LIKE '%".$name."%'
显示一些可能的匹配名称。我当前的控制器功能:
public function search()
{
$name = Input::get('character');
$searchResult = Player::where('name', '=', $name)->paginate(1);
return View::make('search.search')
->with('name', $name)
->with('searchResult', $searchResult);
}
而我的观点:
<form id="custom-search-form" class="form-search form-horizontal pull-right" action="{{ URL::action('CharactersController@search') }}" method="get">
<div class="input-append spancustom">
<input type="text" class="search-query" name="character" placeholder="Character/guild name">
<button type="submit" class="btn"><i class="icon-search"></i></button>
</div>
</form>
提前致谢。