aizhar777/cell
Laravel包,用于生成HTML表格
v1.0
2016-10-28 18:27 UTC
Requires
- donquixote/cellbrush: ^1.0
This package is not auto-updated.
Last update: 2024-09-23 14:27:55 UTC
README
Cell:为Laravel包装“donquixote/cellbrush”的包装器
安装
首先,通过Composer安装此包。
composer require aizhar777/cell
此操作完成后,只需将服务提供者和外观类添加到您的项目配置文件config/app.php中
服务提供者
Aizhar777\Cell\CellServiceProvider::class,
外观
'Cell' => Aizhar777\Cell\Facades\Cell::class,
基本用法
一个简单的3x3表格,对角线单元格被填充。
namespace App\Http\Controllers; class TestController extends Controller { public function index() { $table = \Cell::create() ->addClass('table table-bordered') ->addRowNames(['row0', 'row1', 'row2']) ->addColNames(['col0', 'col1', 'col2']) ->td('row0', 'col0', 'Diag 0') ->td('row1', 'col1', 'Diag 1') ->td('row2', 'col2', 'Diag 2'); return view('test_view', ['table' => $table->render()]); } }
test_view.blade.php
<!-- ... --> {{ $table }} <!-- ... -->
结果
嵌套组
组可以有无限深度。
$table = \Cell::create() ->addRowNames(['T', 'B.T', 'B.B.T', 'B.B.B']) ->addColNames(['L', 'R.L', 'R.R.L', 'R.R.R']) ->td('T', '', 'top') ->td('B', 'L', 'bottom left') ->td('B.T', 'R', 'B.T / R') ->td('B.B', 'R.L', 'B.B / R.L') ->td('B.B.T', 'R.R', 'B.B.T / R.R') ->td('B.B.B', 'R.R.L', 'B.B.B / R.R.L') ->td('B.B.B', 'R.R.R', 'B.B.B / R.R.R');
结果