Laravel WhereIn 不工作
Laravel WhereIn Not Working
为什么这 return 是预期的集合;
$postcodes = DB::table('payments')->whereIn('VendorZIP', array('BS19AA','PO48AA'))->get();
print_r($postcodes);
但是这 return 是一个错误;
$payments = Payment::all();
$payments->whereIn('VendorZIP', array('BS19AA','PO48AA'))->get();
print_r($payments);
错误是;
Call to undefined method Illuminate\Database\Eloquent\Collection::whereIn()
我当然有支付模式;
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Payment extends Model {
//
}
无需在 whereIn()
之前调用 all()
。将您的代码更改为:
$payments = Payment::whereIn('VendorZIP', array('BS19AA','PO48AA'))->get();
您可以在 Eloquent basic usage 文档中找到更多示例。
为什么这 return 是预期的集合;
$postcodes = DB::table('payments')->whereIn('VendorZIP', array('BS19AA','PO48AA'))->get();
print_r($postcodes);
但是这 return 是一个错误;
$payments = Payment::all();
$payments->whereIn('VendorZIP', array('BS19AA','PO48AA'))->get();
print_r($payments);
错误是;
Call to undefined method Illuminate\Database\Eloquent\Collection::whereIn()
我当然有支付模式;
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Payment extends Model {
//
}
无需在 whereIn()
之前调用 all()
。将您的代码更改为:
$payments = Payment::whereIn('VendorZIP', array('BS19AA','PO48AA'))->get();
您可以在 Eloquent basic usage 文档中找到更多示例。