PHP code example of loonatx / laravel-bi-10

1. Go to this page and download the library: Download loonatx/laravel-bi-10 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/ */

    

loonatx / laravel-bi-10 example snippets


StringDimension::create('name', 'The Name');
SumMetric::create('unique_name_for_some_of_prices', 'The Sum');

SumMetric::create('unique_name_for_some_of_prices', 'The Sum')
    ->column('price_column')
    ->color('#FF0000');

DateDimension::create('year_week', 'Year Week')
    ->format('%Y-%u');

BelongsToDimension::create('product_name', 'Product')
    ->relation('product')
    ->otherColumn('name');

DateDimension::create('initial_of_name', 'Initial')
    ->raw('LEFT(name, 1)');

DateDimension::create('discounted_price', 'Discounted Price')
    ->raw('price * 0.9');

BigNumber::create('order_number', 'Orders')

Table::create('table', 'Table')
    ->dimension([
        BelongsToDimension::create('product', 'Product')
            ->relation('product')
            ->otherColumn('name');
    ])
    ->metrics([
        SumMetric::create('price', 'Revenues')
    ]);

BigNumber::create('order_number_with_price_greater_than_10', 'Big Orders')
    ->width('w-1/2')
    ->scope(function(Builder $builder) {
        return $builder->where('price', '>', 10);
    });

Table::create('user-per-country', 'User per Country')
    ->dimensions([
        StringDimension::create('country_code', 'Country'),
    ])
    ->metrics([
        CountMetric::create('count', 'Count'),
    ])
    ->orderBy('count', 'desc')

StringFilter::create('type', 'Type')

public function widgets()
{
    return [
        BigNumber::create('post-count', 'Number of Posts')
            ->metric(CountMetric::create('count', 'Count'))
            ->width('w-1/2')
    ];
}