Skip to content

Examples

Benjamin Khalife edited this page May 15, 2023 · 5 revisions

Example: Get the number of rows along with the total value of the percent field

$result = UserActivity::select(function($s){
            $s->sum('percent')->as('sum');
            $s->count()->as('count');
          })->where('client_id', $client->id)->first();

Output:

{"sum": 160, "count": 3}

Clone this wiki locally