承接 bernadev/laravel-reports 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bernadev/laravel-reports

Composer 安装命令:

composer require bernadev/laravel-reports

包简介

Scaffolding to generate data reports in a unified way

README 文档

README

Scaffolding to generate data reports in a unified way

To install, simply run the following command:

composer require bernadev/laravel-reports

This package is intended to make the creation of new reports faster and easier to maintain. To do so, it establishes an interface all reports must implement. With this library, when you need to create a new report, all you have to do is the following:

  1. Create a route for it
  2. Write a couple of class methods
  3. Write a Blade template to render the results.

This class helps in the following ways:

  1. Artisan command to create new reports. Just run php artisan reports:generate . It will ask for the details of the new report and it will create a class and a view for it.
  2. Interface all report classes must implement with common methods.
  3. Blade view that shows the list of filters. Using Bootstrap 5.

Filtering

Example of how setting the filters work. You have to create an associative array where the key is the name of the field and it contains a set of properties.

    public function __construct(array $input_data=array())
    {
        $this->filters = [
            'start_date' => ['name' => 'Start Date', 'value' => NULL, 'type' => 'date'],
            'end_date' => ['name' => 'End Date', 'value' => NULL, 'type' => 'date']
        ];

        if (Arr::get($input_data, 'start_date'))
        {
            $this->filters['start_date']['value'] = MY::parseDate($input_data['start_date'])->startOfDay();
        }
        else
        {
            $this->filters['start_date']['value'] = now()->subMonth()->startOfDay();
        }

        if (Arr::get($input_data, 'end_date'))
        {
            $this->filters['end_date']['value'] = MY::parseDate($input_data['end_date'])->endOfDay();
        }
        else
        {
            $this->filters['end_date']['value'] = now()->endOfDay();
        }
    }

Example where we filter by a date range and by default the value is -1 month until today.

Controller

The controller and the routing is managed by the developer. You have to make sure there's a route linking to the new report. In that controller/route, in order to load the report all you have to do is something like this:

use Bernadev\LaravelReports\Loader;

public function generate($report, Request $request)
{
   $report = Loader::load($report, $request->all());

   $view_data['report'] = $report;
   $view_data['results'] = $report->generate();

   return view($report->getView(), $view_data);
}
  1. Load the report by passing the "slug" field (set when creating the report).
  2. Pass the report object and the results to the view
  3. Render the view. We can use the getView() method to retrieve its location.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固