我认为这很可能是一个PHP错误,我发现一些帖子有相同的错误,但是我无法从答案中解决问题。
我的代码
class consultController extends Controller
{
public function index(){
return view('pages.consult');
}
public function find(){
$input=Request::all();
$location=$input['location'];
$spec=$input['specialization']
$out = DB::table('doctors')->where('location','=', $location)
->where('specialization_group','=', $specialization)
->get(); //line 23, error here
return $out;
}
}
错误:
FatalErrorException in consultController.php line 23:
syntax error, unexpected '$out' (T_VARIABLE)
用分号解决错误后,我现在收到此错误,
ErrorException in Factory.php line 153:
array_merge(): Argument #2 is not an array
尝试将$ out传递给视图时,
class consultController extends Controller
{
public function index(){
return view('pages.consult');
}
public function find(){
$input=Request::all();
$location=$input['location'];
$spec=$input['specialization'];
$out = DB::table('doctors')->where('location','=', $location)
->where('specialization_group','=', $spec)
->get();
return view('pages.doclist')->with('out',$out);
//return count($out);
}
}
答案 0 :(得分:4)
$spec=$input['specialization']
行缺少分号。
它应该是这样的:
$spec=$input['specialization'];
答案 1 :(得分:2)
试
$out = \DB::table('doctors')->whereLocation(request('location'))
->whereSspecializatioGroup(request('specialization'))
->get();
for laravel 5.1