PHP code example of bluefyn-international / report-engine

1. Go to this page and download the library: Download bluefyn-international/report-engine 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/ */

    

bluefyn-international / report-engine example snippets




namespace App\Reports\User;

use App\Models\User;
use AlwaysOpen\ReportEngine\BaseFeatures\Data\Types\Text;
use AlwaysOpen\ReportEngine\ReportBase;
use Illuminate\Database\Query\Builder;

class UserReport extends ReportBase
{
    protected $autoloadInitialData = true;

    /**
     * @return string
     */
    public function title(): string
    {
        return 'User Maintenance';
    }

    /**
     * @return string
     */
    public function description(): string
    {
        return 'List of all users within the system';
    }

    /**
     * @return Builder
     */
    public function baseQuery(): Builder
    {
        return User::toBase()
            ->select([
                'id',
                'email',
                'name',
            ]);
    }

    /**
     * @return array
     */
    public function availableColumns(): array
    {
        return [
            'name' => [
                'label'      => 'Name',
                'filterable' => true,
                'type'       => new Text(),
            ],
            'email' => [
                'label'      => 'Email',
                'filterable' => true,
                'type'       => new Text(),
            ],
        ];
    }
}




namespace App\Http\Controllers;

use App\Reports\User\UserReport;

class UserController extends Controller
{
    /**
     * @return UserReport
     */
    public function index() : UserReport
    {
        return app(UserReport::class);
    }
}



use App\Http\Controllers\UserController;

Route::get('users', [UserController::class, 'index'])
    ->multiformat();