Try this.
$field = ['name','id','address'];
$name = DB::Table('bookinfo')->Where(function ($query) use($string, $field) {
for ($i = 0; $i < count($field); $i++){
$query->orwhere($field, 'like', '%' . $string .'%');
}
})->get();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…