我正在Laravel中编写一个查询,作为Select different:
protected static $type = DB::table('customers')->distinct('region')->get();
列,区域应该是不同的。
我想在以下方面利用它:
$revenuedetails = DB::table('customers as g')
->select(
DB::raw('DATE(g.created_at) as created_date'),
'g.msisdn',
'g.region',
'g.amount'
)
->whereRaw('g.region' , self::$type[$region] ?? null)
作为where子句参数,但出现此错误:
Symfony \组件\调试\异常\ FatalErrorException(E_UNKNOWN) 常量表达式包含无效的操作
我该如何解决?