starfolksoftware / laravel-dashboard-table-tile
用于在 spatie 的 Laravel Dashboard 中显示表格的瓷砖。
v2.1.1
2023-12-25 05:53 UTC
Requires
- php: ^8.2
- fakerphp/faker: ^1.19
- orchestra/testbench: ^8.0
- spatie/laravel-dashboard: ^3.0
Requires (Dev)
- nunomaduro/laravel-mojito: ^0.2.10
- pestphp/pest: ^2.0
README
一个简单直接的表格瓷砖包。
此瓷砖可用于 Laravel Dashboard。
安装
您可以通过 composer 安装此包
composer require starfolksoftware/laravel-dashboard-table-tile
用法
在仪表板配置文件中,您可以在 tiles 键中添加此配置项(可选)。
'tiles' => [ // ... 'tables' => [ 'refresh_interval_in_seconds' => 300, // Default: 300 seconds (5 minutes) ], ],
以下是一个表格示例
<?php namespace App\Tables; use StarfolkSoftware\TableTile\Table; class ExampleTableTile extends Table { /** * Get the title of the table. * * @return string */ protected function getTitle() { return 'Example Table Tile'; } /** * Get the description of the table. * * @return string */ protected function getDescription() { return 'This is an example table tile.'; } /** * Get the columns to be displayed in the table. * * @return array */ protected function getColumns() { return [ 'name' => [ 'label' => 'Name', ], 'email' => [ 'label' => 'Email', ], 'gender' => [ 'label' => 'Gender', ], 'status' => [ 'label' => 'Status', ], ]; } /** * Get the rows to be displayed in the table. * * @return array */ protected function getRows() { $faker = \Faker\Factory::create(); return collect(range(1, 100))->map(function ($i) use ($faker) { return [ 'name' => $faker->name, 'email' => $faker->email, 'gender' => $faker->randomElement(['male', 'female']), 'status' => $faker->randomElement(['paid', 'unpaid']), ]; }); } /** * Get the filters to be applied to the table. * * @return array */ protected function getAvailableFilters() { return [ 'gender' => [ 'label' => 'Gender', 'values' => [ 'male', 'female', ], ], 'status' => [ 'label' => 'Status', 'values' => [ 'paid', 'unpaid' ], ] ]; } /** * Get the columns that can be searched. * * @return array */ protected function getSearchableColumns() { return ['name', 'email']; } }
在您的仪表板视图中,您使用 livewire:table-tile
组件。
<x-dashboard> <livewire:table-tile position="e7:e16" /> </x-dashboard>
测试
composer test
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
贡献
有关详细信息,请参阅 CONTRIBUTING。
安全
如果您发现任何与安全相关的问题,请通过 :author_email 发送电子邮件,而不是使用问题跟踪器。
鸣谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件。