Auth::user()->products->sum('price');
The documentation is a little light for some of the Collection
methods but all the query builder aggregates are seemingly available besides avg()
that can be found at http://laravel.com/docs/queries#aggregates.
More Related Contents:
- Laravel one to many relation with a one to one relation
- How to Create Multiple Where Clause Query Using Laravel Eloquent?
- How do I get the query builder to output its raw SQL query as a string?
- Bulk Insertion in Laravel using eloquent ORM
- Laravel Check If Related Model Exists
- Laravel, sync() – how to sync an array and also pass additional pivot fields?
- How to alias a table in Laravel Eloquent queries (or using Query Builder)?
- Laravel Model with Two Primary Keys update [duplicate]
- Laravel eager loading with limit
- Laravel 5.2 – Use a String as a Custom Primary Key for Eloquent Table becomes 0
- Laravel Eloquent: How to order results of related models?
- Laravel 4: how to “order by” using Eloquent ORM [duplicate]
- How to exclude certains columns while using eloquent
- How to alias the name of a column in Eloquent
- Laravel $q->where() between dates
- Laravel – Database, Table and Column Naming Conventions?
- How to Make Laravel Eloquent “IN” Query?
- How to Merge Two Eloquent Collections?
- Update without touching timestamps (Laravel)
- laravel collection to array
- Laravel Eloquent sort by relation table column
- Eloquent Parent-Child relationship on same model
- Laravel 4.1: How to paginate eloquent eager relationship?
- Laravel Eloquent: How to get only certain columns from joined tables
- How can I query raw via Eloquent?
- Find or Create with Eloquent
- A __construct on an Eloquent Laravel Model
- How to get last insert id in Eloquent ORM laravel
- Laravel Many to many self referencing table only works one way
- Merge ‘with’ and ‘whereHas’ in Laravel 5