LaravelORM 中的 withSum , withAvg, withMax,withMin 的實現

helong3314發表於2022-01-12

LaravelORM 中的 withSum , withAvg, withMax,withMin 的實現

User::withCount(['price as ratio_price'=>function($query){
    $query->select(DB::raw("ROUND(sum(price),2) as ratio_price"))}])
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章