$input = Input::all();
$user = User::where(function($q) {
$q->where('email', $input['email'] )
->orWhere('email', $input['emails'][0]['value'] );
})
->first();
print_r($user);die;
总是说Undefined变量:输入
比较电子邮件与两个值的最佳方法是什么,请指导
解决方法:
添加use($input)将$input变量传递给闭包范围:
User::where(function ($q) use ($input) {
Closures may also inherit variables from the parent scope. Any such variables must be passed to the
use
language construct.