Reputation: 4886
Can any one tell me why i am getting error for the following code.
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));
}
ERROR
Undefined variable: qid1
Then i tried to pass the $qid inside the function like this
$users = User::where('event','=',$event)->orderby('name')->with(array('answer'=>function($q,$qid1){
$q->where('question_id','=',$qid1)->orWhere('question_id','=',$qid1+1);
}))->get();
ERROR
Missing argument 2 for AdminController::{closure}()
Upvotes: 0
Views: 566
Reputation: 4680
I don't use laravel but if you expect them as parameter laravel doesn't know that, which is why you have to use
function() use($expected, $parameters) {
In your case it is
function() use($q, $qid1) {
Upvotes: 2