PHP code example of dev-pirate / lara-report-craft
1. Go to this page and download the library: Download dev-pirate/lara-report-craft library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dev-pirate / lara-report-craft example snippets
namespace App\Reports;
use App\Models\Example;
use Carbon\Carbon;
use DevPirate\LaraReportCraft\Facades\GeneralReport;
class ExampleReport extends GeneralReport
{
protected string $reportTitle = 'Example report testing';
protected array $columns = [
['field' => 'order_date', 'title' => 'Order Date'],
['field' => 'region', 'title' => 'Région'],
['field' => 'rep', 'title' => 'Rep order'],
['field' => 'item', 'title' => 'Item N°'],
['field' => 'unit', 'title' => 'Unit code'],
];
public function generate_report(): array
{
return array_map(function ($example) {
return [
'order_date' => Carbon::parse($example['orderDate'])->format('d/m/Y') ?? '',
'region' => $example['region'],
'rep' => $example['rep'],
'item' => $example['item'],
'unit' => $example['unit']
];
}, Example::all()->toArray());
}
}
return [
'reports_path' => app_path('Reports')
// other configuration parameters
];
bash
php artisan vendor:publish --provider="DevPirate\LaraReportCraft\Providers\LaraReportCraftProvider"
bash
Route::middleware([
'api',
\Fruitcake\Cors\HandleCors::class,
])->group(function() {
LaraReportCraft::routes();
});
// \Fruitcake\Cors\HandleCors middleware are