Skip to content

Commit 60c67be

Browse files
committed
update readme
1 parent 16a08bd commit 60c67be

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ class Invoice extends Model
2727

2828
## Usage
2929

30-
If you want to summarize the columns of results from a relationship without actually loading them and by one request to the database you may use the `withSum` method, which will place a `relation_column_sum` column on your resulting models. For example:
30+
If you want to get results from a relationship without actually loading them and by one request to the database you may use the these methods, which will place a new columns on your resulting models. For example:
3131
```php
3232
$invoices = Invoice::withSum('items:price,price2')->get();
33+
echo $invoices[0]->items_price_sum;
34+
$invoices = Invoice::withMin('items:price,price2')->get();
35+
echo $invoices[0]->items_price_min;
3336
```
37+
The following methods apply to all methods.!!!
3438
You may add the "sum" for multiple relations as well as add constraints to the queries:
3539
```php
3640
use Illuminate\Database\Eloquent\Builder;

0 commit comments

Comments
 (0)