本文介绍了如何在laravel 4.2中检查具有两个值的一个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$input = Input::all();


$user = User::where(function($q) {
          $q->where('email', $input['email'] )
            ->orWhere('email', $input['emails'][0]['value'] );
      })
      ->first();

   print_r($user);die;

总是说未定义变量:输入 比较带有两个值的电子邮件的最佳方法是什么?

Always says Undefined variable: input What is the best way to compare email with two values please guide

推荐答案

添加use($input)$input变量传递到闭包范围:

Add use($input) to pass the $input variable to the closure scope:

User::where(function ($q) use ($input) {

http://php.net/manual/en/functions.anonymous.php

这篇关于如何在laravel 4.2中检查具有两个值的一个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 20:24