我是 laravel 的新手。我正在尝试从选择列表中构建查询。我收到以下错误
strtolower() 期望参数 1 是字符串
这是我的表格
<form action="search" method="post" accept-charset="utf-8">
<div class="form-group">
<select name="temptype" class="form-control">
<option value="" selected="selected">Select Temp Type</option>
<option value="hygienist" >Hygienist</option>
<option value="dentist" >Dentist</option>
<option value="dentalassistant" >Dental Assistant</option>
</select>
</div><!-- end username form group -->
</div><!-- end .modal-body -->
<div class="modal-footer">
<input type="submit" name="submit" class="btn btn-primary" />
</div>
</form>
这是我的路线
Route::post('search', function(){
$temp = User::getTemps();
return $temp;
});
这是我的用户模型中的方法...
public static function getTemps()
{
$type = array (
'hygienist' => Input::get('hygienist'),
'dentist' => Input::get('dentist'),
'dentalassistance' =>Input::get('dentalassistance')
);
$temps = DB::table('users')
->select('usertype', $type) <---- I think this has to be a string but my question is how do I make this dynamic... How do I pass the string value from what the user selects and pass it into the query?>
->get();
return $temps;
}