Laravel-常量表达式在“选择不同的对象”中

时间:2019-07-08 15:53:53

标签: laravel

我正在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)   常量表达式包含无效的操作

我该如何解决?

0 个答案:

没有答案