PHP code example of ardenthq / nova-table-metrics

1. Go to this page and download the library: Download ardenthq/nova-table-metrics 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/ */

    

ardenthq / nova-table-metrics example snippets


class GreatestShows extends Table
{
    public function title() : string
    {
        return 'Greatest TV shows';
    }

    public function heading() : string
    {
        return 'Title';
    }

    public function detailHeading() : string
    {
        return 'Views';
    }

    public function defaultPeriod() : ?Period
    {
        return Period::Day;
    }

    /**
     * @return Collection<int, TableRow>
     */
    public function items(?Period $period) : Collection
    {
        return collect([
            TableRow::make('Silicon Valley', '42,184')
                    ->url('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
                    ->openInNewTab(),

            //
        ]);
    }
}

class GreatestShows extends Table
{
    public function title() : string
    {
        return 'Greatest TV shows';
    }

    public function heading() : string
    {
        return 'Title';
    }

    public function detailHeading() : string
    {
        return 'Views';
    }

    public function defaultPeriod() : ?Period
    {
        return null;
    }

    /**
     * @return Collection<int, TableRow>
     */
    public function items(?Period $period) : Collection
    {
        return collect([
            TableRow::make('Silicon Valley', '42,184')
                    ->url('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
                    ->openInNewTab(),

            //
        ]);
    }

    public function hasPeriodSelector() : bool
    {
        return false;
    }
}

class Main extends Dashboard
{
    public function name()
    {
        return 'Dashboard';
    }

    public function cards()
    {
        return [
            // ...
            GreatestShows::make()->width('1/3'),
        ];
    }
}

bash
composer analyse