suminagashi/figures

为您的 symfony 应用提供简单的统计。

维护者

详细信息

github.com/suminagashi/figures

源代码

安装: 13

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

类型:symfony-bundle

dev-master 2020-08-02 11:14 UTC

This package is auto-updated.

Last update: 2024-09-29 05:55:48 UTC


README

# Figures

为您的 symfony 应用提供简单的统计。

安装包

即将推出 Flex 烹饪配方...

注册包

// config/bundles.php

return [
    ...
    Suminagashi\FiguresBundle\FiguresBundle::class => ['all' => true],
];

将 Figure 实体添加到您的数据库

php bin/console doctrine:schema:update --force

设置您的实体

首先您需要导入 Suminagashi\FiguresBundle\Annotation\Watch 注解。然后您必须写入统计的键、类型(累积或计数)以及生命周期(在哪个生命周期中注册统计)。

use Suminagashi\FiguresBundle\Annotation\Watch;

class Product
{
    //...

    /**
     *
     * @ORM\Column(type="integer")
     *
     * @Watch(key="product:price", type="cumul", lifecycle="update")
     * @Watch(key="product:sell", type="count", lifecycle="create")
     */
    private $price;

    //***

这是如何工作的

统计计算有两种模式

  • count 用于计算销售数量(例如)
  • cumul 用于计算销售金额(例如)

如何获取特定统计

首先您需要在您的代码中导入 Suminagashi\FiguresBundle\Tools\Figures。然后您可以将类自动注入并开始使用它。我们提供了一些方法来帮助您

$figures = new Figures();

$figures->all('key');
$figures->getToday('key');
$figures->getLastweek('key');
$figures->getLastmonth('key');
$figures->getLastyear('key');
$figures->get('key', 'start', 'end');

即将推出

  • 统计百分比计算
  • 统计类型
  • 更好的异常处理
  • 处理删除(级联)