定制 agoalofalife/reports 二次开发

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

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

agoalofalife/reports

最新稳定版本:v0.3.0

Composer 安装命令:

composer require agoalofalife/reports

包简介

UI for created and download reports in Laravel

README 文档

README

Requirements : PHP verison >= 7.1.0 Laravel version >= 5.5

not support Laravel version 5.8 & >

What is it?

This is package offers ready UI and some code, for reports.

Reports will be with extensions: pdf, xlxs, xls, csv .

In the paradigm Laravel, we make reprots and write code. It's just!

Install

composer require agoalofalife/reports
php artisan reports:install

Locale

In file config/app.php select your language.

The package provides two languages:

  • ru
  • en

Blade and UI

In your template, you need to paste the code

  <body>
    @include('reports::app')
    ...

Cron

You have to add cron, how separete process.

// App\Console\Kernel
use agoalofalife\Reports\Console\ParseReportsCommand;

  $schedule->command(ParseReportsCommand::class)->everyMinute();

The development process

You create new file report:

php artisan make:report NameReport

Insert in config config/reports.php :

  'reports' => [
          \App\Reports\TestReport::class
    ],

Fill the class:

<?php
declare(strict_types=1);
namespace App\Reports;

use agoalofalife\Reports\Contracts\HandlerReport;
use agoalofalife\Reports\Report;

class TestReport extends Report implements HandlerReport
{
    /**
     * Disk for filesystem
     * @var string
     */
    public $disk = 'public';

  /**
     * Format export : xls, xlsx, pdf, csv
     * @var string
     */
    public $extension = 'xlsx';

     /**
     * Get file name
     * @return string
     */
    public function getFilename() : string
    {
        return 'TestReport';
    }

    /**
     * Get title report
     * @return string
     */
    public function getTitle() : string
    {
        return 'Test';
    }

    /**
     * Get description report
     * @return string
     */
    public function getDescription() : string
    {
        return 'Description test report';
    }

    /**
     * @param $excel
     * @return bool
     */
    public function handler($excel) : bool
    {
      $excel->sheet('Sheetname', function ($sheet) {
            $sheet->rows(array(
                array('test1', 'test2'),
                array('test3', 'test4')
            ));
        });
      return true;
    }
}

Property $disk, name disk in filesystem.

Property $extension, type extension your file.

Method getFilename accordingly return name file.

Method getTitle return name title in UI.

Method getDescription return description in UI.

Method handler is base method. Package use external package.

Method is a small wrapper.

Notification

Once the report is ready, you can send notification.

For this you need to implement interface agoalofalife\Reports\Contracts\NotificationReport.

Method getNotifiable return notifiable, which has a method routeNotificationFor.

And method getNotification, return Notification type.

    // implements agoalofalife\Reports\Contracts\NotificationReport
    public function getNotifiable()
    {
        return User::where('email', 'test@gmail.com')->get()->first();
    }

    public function getNotification(): Notification
    {
        return new InvoicePaid();
    }
// app/User.php

    public function routeNotificationForSlack($notification)
    {
        return 'hook';
    }

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-12