定制 ppranav/table-insights 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ppranav/table-insights

最新稳定版本:1.6

Composer 安装命令:

composer require ppranav/table-insights

包简介

TableInsights is a powerful package designed specifically for back-end developers using the Laravel framework. It allows for easy conversion of database tables into meaningful statistics and insights using just a model.

README 文档

README

TableInsights is a powerful package designed specifically for back-end developers using the Laravel framework. It allows for easy conversion of database tables into meaningful statistics and insights using just a model.

Getting Started

Prerequisites

  • Laravel Framework

Installation

You can install the package via composer:

composer require ppranav/table-insights

You can load the package's config file by running:

php artisan vendor:publish --tag=tableinsights

The config file allows you to customize the tableinsights's settings.

You can customize the key names of your Tableinsights array and enable or disable individual keys to better suit your needs. To change a key name, enter/replace the desired key name in the right field.

Usage

Extend the class \Ppranav\TableInsights\TableInsights in your own class and implement a models() method in the following code:

/**
 * Add arrays of models
 * @return array<Model, string>
 */
public function models() {
    return [
        Project::class => 'created_at',
        TaskLog::class => 'committed_at'
    ];
}

You may also update models query using the following code:

public function setQuery(Activity $activity)
{
    return $activity->query()->where(‘user_id’, auth()->id());
}

Finally, Your Implementation class should look like this:

class Dashboard extends TableInsights
{

    /**
     * Add arrays of models
     * @return array<Model, string>
     */
    public function models() {
        return [
            Project::class => 'created_at',
            TaskLog::class => 'committed_at'
        ];
    }

    public function setQuery(Activity $activity)
    {
        return $activity->query()->where('created_for_id', auth()->id());
    }
}

Show insights in a controller

 return (new Dashboard())->getInsights();

Screenshots

App Screenshot

License

MIT

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-27