bensampo/laravel-count-totals
Composer 安装命令:
composer require bensampo/laravel-count-totals
包简介
Elegantly count totals
README 文档
README
Inspired by Jonathan Reinink's post about Calculating totals in Laravel using conditional aggregates I've created an elegant way to grab multiple totals in an efficient way.
Please see the post for details about what this package aims to solve.
Install
composer require bensampo/laravel-count-totals
Usage
Given the following subscribers table structure:
| name | status |
|---|---|
| Adam Campbell | confirmed |
| Taylor Otwell | confirmed |
| Jonathan Reinink | bounced |
| Adam Wathan | cancelled |
$totals = Subscriber::countTotals([ ['status' => 'confirmed'], ['status' => 'cancelled'], ['name' => 'Jonathan Reinink'], ]); $totals->confirmed // 2 $totals->cancelled // 1 $totals->jonathanReinink // 1
You may also use the DB facade:
$totals = DB::table('subscribers')->countTotals([ ['status' => 'confirmed'], ['status' => 'cancelled'], ['name' => 'Jonathan Reinink'], ]);
统计信息
- 总下载量: 47
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-23