asivas/analytics-dashboard
Composer 安装命令:
composer require asivas/analytics-dashboard
包简介
The "CRUD-Resouce" Analytics Dashboard controller, to be used as part of the Asivas solution for https://gitlab.com/asivas/larvue-abm/ABM
README 文档
README
The "CRUD-Resouce" Analytics Dashboard controller, to be used as part of the Asivas solution for https://gitlab.com/asivas/larvue-abm/ABM, to simple manage CRUD of resources, for backend usage, (expecting to use the asivas vue ABM frontend).
##Requirements
Instalation / Configuration
You can install this package using composer
comopser require asivas/analytics-dashboard
Once you have required the package the configuration requires this 2 steps:
-
Create your Analitycs Facade class in app\Facades
This class should have a method for every analytics the app could graph or analyze. Each method will end up calling ths getData method of an Specific-Analytic class wich extends Asivas\Analytics\Analytics
<?php namespace App\Facades; use App\Analytics\SomeMetricsIndicator; class Analytics { /** ** IMPORTANT ** This method must be present, otherwise getWidgetData won't be able to build the proper response */ public function getWidget($analyticsName):Widget { $dwc = new DashboardWidgetController(); return $dwc->getWidget($analyticsName); } //** */ public function someMetricsIndicator($from,$to,$params = null) { return SomeMetricsIndicator::getData($from,$to,$params); } // TODO: create the methods similiar to someMetricsIndicator with your criteria }
-
Create your DashboardWidgetController extending the Asivas\Analytics\Http\Controllers\Dashboard\DashboardWidgetController This class should be the one creating the panels and widgets of the app's dashboard.
namespace App\Http\Controllers\Dashboard; use Asivas\Analytics\Http\Controllers\Dashboard\DashboardWidgetController as AsivasDashboardWidgetController; class DashboardWidgetController extends AsivasDashboardWidgetController { .... }
-
Register the Facades Analytcs to return new instance of the class from (1) and WidgetController to return new instance of the class from (2) in app\Providers\AppServiceProvider register method
use App\Facades\Analytics; use App\Http\Controllers\Dashboard\DashboardWidgetController; class AppServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { // $this->app->bind('Analytics', function($app) { return new Analytics(); }); $this->app->bind('WidgetController', function($app) { return new DashboardWidgetController(); }); } ...
-
Add Analytics alias pointing to Asivas\Analytics\AnalyticsFacade class in the 'aliases' key of config/app.php
'aliases' => [ ... 'Analytics' => \Asivas\Analytics\AnalyticsFacade::class, 'WidgetController' => \Asivas\Analytics\WiggetControllerFacade::class ...
-
For every analysis the app should graph or show in the dashboard
Create a Specific-Analytics class in App\Analytics extending Asivas\Analytics\Analytics implementing the addJoins, addGroupBys and addWheres methods
<?php namespace App\Analytics; use App\Models\Report; use Asivas\Analytics\Analytics; use Illuminate\Database\Eloquent\Builder; class SomeMetricsIndicator extends Analytics { protected $mainModel = SomeModel::class; protected function addJoins(Builder $q) { return $q->selectRaw('COUNT(some_related_model.created_at) as somemodels, \'assigned\' as status') ->join('some_related_models','somemodels.id', '=','some_related_models.somemodel_id') ->join('other_related_models','somemodels.id', '=','other_related_models.somemodel_id') ->join('related_to_others','other_related_models.related_to_other_id', '=','related_to_others.id') ->join('users','related_to_others.user_id', '=','users.id'); } protected function addGroupBys(Builder $q) { return $q->groupBy('status'); } protected function addWheres(Builder $q, $from, $to) { return $q->whereHas('assignations',function ($q) use($from,$to){ $q->whereNull('rejected_date') ->where('users.id',request('user')); }); } }
asivas/analytics-dashboard 适用场景与选型建议
asivas/analytics-dashboard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 93 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 asivas/analytics-dashboard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 asivas/analytics-dashboard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 93
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-07