norman-huth/markdown

v1.0.3 2023-10-14 09:09 UTC

This package is auto-updated.

Last update: 2024-09-14 11:05:13 UTC


README

安装

composer require norman-huth/markdown

Markdown表格生成器

基本用法

创建此表格

| ID | Name          |
|:---|:--------------|
| 1  | Administrator |
| 2  | User          |
| 4  | Hugo          |

逐行

use NormanHuth\Markdown\Table;

$table = new Table();

$table->addCell('ID');
$table->addCell('Name');

$table->addRow([1, 'John Doe']);
$table->addRow([2, 'Johanna Doe']);

echo $table->render();

数组或 \Illuminate\Support\Collection

use NormanHuth\Markdown\Table;

$table = new Table();

$table->addCell('ID');
$table->addCell('Name');

$table->addRows(
    [
        [1, 'John Doe'],
        [2, 'Johanna Doe'],
    ]
);

echo $table->render();

Laravel模型集合

use NormanHuth\Markdown\Table;

$table = new Table();
$table->addCell('ID');
$table->addCell('Name');
$table->addRows(\App\Models\User::all(['id', 'name']));

return $table->render();