agoalofalife / reports
UI for created and download reports in Laravel
Installs: 1 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: >=7.1.0
- maatwebsite/excel: ~2.1.0
Requires (Dev)
- fzaninotto/faker: ^1.6
- mockery/mockery: ^0.9.9
- orchestra/testbench: ~3.5
- phpunit/phpunit: ~6.0
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'; }