1. Go to this page and download the library: Download shanjing/laravel-statistics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Models\Order;
use Illuminate\Database\Eloquent\Model;
use Shanjing\LaravelStatistics\Traits\Statistics;
class Order extends Model
{
use Statistics;
protected $table = '';
protected $connection = '';
}
// period year | month | week | day
// occurredBetween 时间范围
// orderBy desc | asc
Order::period("day")
->occurredBetween(["20210718", "20210921"])
->selectRaw('count(id) as total') // 支持 select 语句
->selectRaw('SUM(`price`) as gmv') // 支持 select 语句
->orderBy('desc')
->summary();
bash
php artisan laravel-statistics:publish
bash
php artisan laravel-statistics:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.