定制 rishadblack/wire-reports 二次开发

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

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

rishadblack/wire-reports

Composer 安装命令:

composer require rishadblack/wire-reports

包简介

Create responsive, real-time report views in Laravel using WireReports. Powered by Livewire, this package allows effortless exporting to PDF, Excel, or print, streamlining your reporting process.

README 文档

README

WireReports is a Laravel package designed to facilitate the creation of dynamic Livewire report components. It includes features for exporting reports to PDF and Excel formats and offers an easy way to generate and manage report components with custom views and data builders.

Features

  • Create Livewire report components with a single command
  • Export reports to PDF using SnappyPdf or mPDF
  • Export reports to Excel using Maatwebsite\Excel
  • Customizable views for reports
  • Supports hierarchical folder structure for components and views

Installation

To install the package, you can use Composer:

composer require rishadblack/wire-reports

Publishing Stubs

To publish the package stubs for customization, run:

php artisan vendor:publish --provider="Rishadblack\WireReports\WireReportsServiceProvider" --tag="wire-reports-stubs"

Usage

Creating a Report Component

You can create a new Livewire report component using the Artisan command:

php artisan make:wire-reports {name}

The {name} argument should be the name of the component. You can include subfolders by using dot notation (e.g., Demo.Test). Example

To create a report component named TestReport in the Demo folder:

php artisan make:wire-reports Demo.Test

This will create:

A Livewire component file at app/Livewire/Reports/Demo/TestReport.php
A Blade view file at resources/views/livewire/reports/demo/test-report.blade.php

Deleting a Report Component

You can delete an existing Livewire report component using the Artisan command:

php artisan delete:wire-reports {name}

The {name} argument should be the name of the component to delete. It will remove both the component class and the associated view file. Example

To delete the TestReport component from the Demo folder:

php artisan delete:wire-reports Demo.Test

This will remove:

The Livewire component file at app/Livewire/Reports/Demo/TestReport.php
The Blade view file at resources/views/livewire/reports/demo/test-report.blade.php

Customizing the Report Component

Edit the generated component file to define your report's data builder and view:

<?php

namespace App\Livewire\Reports;

use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Rishadblack\WireReports\ReportComponent;

class TestReport extends ReportComponent
{
     public function configure(): void
    {
        $this->setFileName('purchase-report');
    }

    public function builder(): Builder
    {
        return Country::query();
    }

    public function columns(): array
    {
        return [
            Column::make('Serial', 'id')->sortable()->hide(),
            Column::make('Name', 'name')->sortable()->searchable(),
            Column::make('Phonecode', 'phonecode')->sortable(),
        ];
    }

    public function filters(): array
    {
        return [
            Filter::make('Search Name', 'name')->filter(function (Builder $query, string $value) {
                $query->where('name', 'like', "%{$value}%");
            })->placeholder('Search Country Name'),
            Filter::make('Search Supplier', 'phonecode')->searchComponent('contact::search.customers')->filter(function (Builder $query, string $value) {
                $query->where('phonecode', 'like', "%{$value}%");
            })->placeholder('Search Country Name'),
        ];
    }
}

Edit the Blade view file to customize the report layout:

<div>
    <x-wire-reports::table>
        <x-slot:header>
            <x-wire-reports::table.tr>
                <x-wire-reports::table.td colspan="3" style="text-align: center; font-weight: bold;">
                    <h3>Report</h3>
                </x-wire-reports::table.td>
            </x-wire-reports::table.tr>
        </x-slot:header>
        <x-slot:thead>
            <x-wire-reports::table.tr>
                @foreach ($columns as $column)
                    <x-wire-reports::table.th :name="$column['name']" :$column>
                        {{ $column['title'] }}
                    </x-wire-reports::table.th>
                @endforeach
            </x-wire-reports::table.tr>
        </x-slot:thead>
        <x-slot:tbody>
            @foreach ($datas as $data)
                <x-wire-reports::table.tr>
                    @foreach ($columns as $column)
                        <x-wire-reports::table.td :name="$column['name']" :$column>
                            {{ $data->{$column['name']} }}
                        </x-wire-reports::table.td>
                    @endforeach
                </x-wire-reports::table.tr>
            @endforeach
        </x-slot:tbody>
        <x-slot:tfoot>
            <x-wire-reports::table.tr>
                <x-wire-reports::table.td colspan="2">
                    Total Amount
                </x-wire-reports::table.td>
                <x-wire-reports::table.td>
                    {{ $datas->sum('id') }}
                </x-wire-reports::table.td>
            </x-wire-reports::table.tr>
        </x-slot:tfoot>
    </x-wire-reports::table>
</div>

License

This package is licensed under the MIT License. See LICENSE for more details.

Contributing

Contributions are welcome! Please refer to CONTRIBUTING.md for guidelines.

Support

For issues or feature requests, please open an issue on the GitHub repository.

rishadblack/wire-reports 适用场景与选型建议

rishadblack/wire-reports 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「WireReports」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rishadblack/wire-reports 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rishadblack/wire-reports 我们能提供哪些服务?
定制开发 / 二次开发

基于 rishadblack/wire-reports 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2024-09-19