PHP Classes

File: site/demos/grid-totals.php

Recommend this page to a friend!
  Packages of Boss Ibrahim Mussa   Caelrik   site/demos/grid-totals.php   Download  
File: site/demos/grid-totals.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Caelrik
Build Web user interface from PHP components
Author: By
Last change:
Date: 8 days ago
Size: 1,349 bytes
 

 

Contents

Class file image Download
<?php

use Caelrik\Ui\Components\Grid;
use Caelrik\Ui\Components\Grid\Column;

return Grid::make('expenses')
    ->caption('Expenses by team')
    ->column('team', 'Team', static fn (Column $column) => $column->hidden())
    ->column('item', 'Item')
    ->column('date', 'Date')
    ->column('amount', 'Amount', static fn (Column $column) => $column->total()->className('text-end'))
    ->column('nights', 'Nights', static fn (Column $column) => $column->total('avg', 1)->className('text-end'))
    ->groupBy('team')
    ->pageSize(10)
    ->rows([
        ['team' => 'Sales', 'item' => 'Flights', 'date' => '2026-10-02', 'amount' => 1240.5, 'nights' => 4],
        ['team' => 'Design', 'item' => 'Font licences', 'date' => '2026-10-05', 'amount' => 380, 'nights' => null],
        ['team' => 'Sales', 'item' => 'Hotel', 'date' => '2026-10-06', 'amount' => 860, 'nights' => 4],
        ['team' => 'Engineering', 'item' => 'Tickets', 'date' => '2026-10-09', 'amount' => 1500, 'nights' => 2],
        ['team' => 'Design', 'item' => 'Usability study', 'date' => '2026-10-12', 'amount' => 2200, 'nights' => 1],
        ['team' => 'Engineering', 'item' => 'Laptops', 'date' => '2026-10-15', 'amount' => 4800, 'nights' => null],
        ['team' => 'Sales', 'item' => 'Client dinner', 'date' => '2026-10-20', 'amount' => 145.75, 'nights' => null],
    ]);