Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

Tables

Latest Version on PackagistBuild StatusQuality ScoreTotal Downloads

Features:

  • Easily create tables/data reports/exports
  • Support multiple formats (CSV, HTML)
  • Usable for data export with custom business logic

Installation

You can install the package via composer:

composer require brilliant-code/table

Usage

Imagine you need to build this table:

+---------+----------------+----------+
| Count || 3 |
+---------+----------------+----------+
| John | john@mail.com | pwdjohn || Mike | mike@mail.com | mikepwd || Another | another@my.com | password |
+---------+----------------+----------+

Write the following Table-class:

finalclass UsersTable extends Table
{
/** @var User[] */private$users;
publicfunctionquery(): array
{
return [
'users' => User::withCount()->get(),
];
}
/** * Allowed sources to display */publicfunctionsources(): array
{
return [CsvSource::class, HtmlSource::class];
}
publicfunctionhandle(Source$source)
{
$users = $this->users;
$source->addRow(['Count', '', $users->count]);
foreach ($usersas$user){
$source->addRow([$user->name, $user->email, $user->password]);
}
return$source;
}
}
// And Usage:echo (newUsersTable)->display(HtmlSource::class);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Pull requests are welcome. Thank you :)

Credits

License

The MIT License (MIT). Please see License File for more information.

About

[WIP] Easily create tables. Support multiple formats (CSV, HTML). Usable for data export with custom business logic

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages