未定义的变量:在laravel函数中

时间:2015-08-27 07:12:37

标签: php laravel-4 controller

任何人都可以告诉我为什么我收到以下代码的错误。

public function postFormfilehandellerpre(){
        $event = Input::get('event');

        if($event =="Rescom Summit Bangalore 2015")
        $qid1 = "3124";

        $users = User::where('event','=',$event)->orderby('name')->with(array('answer'=>function($q){
            $q->where('question_id','=',$qid1)->orWhere('question_id','=',$qid1+1);
        }))->get();


        return Redirect::to('admin/formfilehandellerpre')->with(array('liusers'=>$users,'liev'=>$event));
    }

错误

Undefined variable: qid1

然后我试图在函数中传递$ qid,就像这样

$users = User::where('event','=',$event)->orderby('name')->with(array('answer'=>function($q,$qid1){
            $q->where('question_id','=',$qid1)->orWhere('question_id','=',$qid1+1);
        }))->get();

错误

Missing argument 2 for AdminController::{closure}()

0 个答案:

没有答案