Download the PHP package mokhosh/laravel-reporter without Composer
On this page you can find all versions of the php package mokhosh/laravel-reporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mokhosh/laravel-reporter
More information about mokhosh/laravel-reporter
Files in mokhosh/laravel-reporter
Package laravel-reporter
Short Description Create PDF and Excel reports in Laravel and style them with Tailwind CSS.
License MIT
Homepage https://github.com/mokhosh/laravel-reporter
Informations about the package laravel-reporter
Create PDF and Excel reports in Laravel and style them with Tailwind CSS
This is basically going to be a wrapper for an Excel generator and a Pdf generator. For the time being these generators are Maatweb and Barry's snappy, that might change in the future.
There is already a package that does this, but I didn't like the API, the coding style and the overall design, with all due respect of course.
Requirements
This package requires PHP 8.
Installation
You can install the package via composer. Make sure to run the Artisan install command to install npm dependencies.
You shouldn't need to do anything else on your client. But on some servers you might need more dependencies. For example on Ubuntu you can run ldd chrome | grep not
and it will give you a list of dependencies that Headless Chrome needs to run but you don't have. Then you can install them by running apt install
. Here's a guide to help you with that:
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
Usage
This is the simplest way to get a PDF. This will report all non-hidden columns:
If you prefer to download the PDF file instead of showing it in the browser you can do this:
You can download the Excel version of your report:
Styles and Transforms
If you don't pass a filter, Reporter
will use your database columns to create its table.
But if you use a filter, you can use any accessor
on your model, and you can filter out some columns like this
That will use a Title Case version of column names for your table headers. If you wish to use custom table headers you can do so like this:
You can also transform the data by passing a closure:
You can add Tailwind CSS classes to your table cells if you want. Cool, right?
You can also mix and match in a million ways:
The whole
modelis also passed to the
transform` closure, so you can access other columns if needed:
With this you can even create made-up columns that don't exist on your model and in your database:
Note that because this column does not really exist as a database column or even an accessor on your model, the first argument will be null
. That's why I've named it $_
.
You can also change the Title of the generated pdf and add metadata
You can decide to show generation date, total pages and page number in footer
You can put your logo in the header
TODO
- [ ] I'm thinking of adding header classes
I'm also thinking of conditional classes that are added to a cell when its content meets a condition passed through a closure that returns a boolean value.
- [ ] A good API for is passing default styles for the table header, and even/odd rows
- [ ] Add headers and footers with page number, date, etc.
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Mo Khosh
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
All versions of laravel-reporter with dependencies
illuminate/support Version ^8.0
maatwebsite/excel Version ^3.1
nesk/puphpeteer Version ^2.0