拉拉维尔 4/5 搜索表单喜欢
我有一个搜索表单和功能,全部完成。只是问,是否可以在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>
提前致谢。