Laravel-admin 實現一個分組求和的資料展現

iVerywang發表於2019-02-27

file

file

    protected function totalGrid()
    {
        $grid = new Grid(new MerchantStatistic);
        $grid->model()->groupBy('merchant_id')->select([DB::raw("sum(count) as total"),'merchant_id']);
        $grid->merchant_id('商戶名')->display(function ($value) {
            return $this->merchant->name ;
        });

        return $grid;
    }

善始善終 嗯!

相關文章