careset/zermelobladecard

Zermelo,Laravel 的 PHP 报告引擎。Bootstrap 卡报告引擎

v1.1.0 2021-02-28 17:31 UTC

This package is auto-updated.

Last update: 2024-09-25 22:20:59 UTC


README

基于 Blade 的 Bootstrap 4.1+ 卡视图,用于 Zermelo 报告引擎

如何开始使用它

安装

此包需要 Zermelo 包。您需要遵循 zermelo 安装说明,了解如何配置您的应用程序使用 zermelo。

完成后,使用 composer 进行安装,并使用 artisan 进行卡报告的配置

composer require careset/zermelobladecard

然后使用 artisan 进行配置

php artisan install:zermelobladecard

这可能会要求您确认替换某些资源...您可以安全地选择是否替换,这对结果影响不大。

卡片的工作原理

卡片基于 Bootstrap 卡系统,通过 blade 模板实现。

在卡片报告中出现的某些功能在其他报告类型中不会出现,具体如下

  • is_fluid() 函数确定是否使用流体布局
  • cardWidth() 函数设置每张卡的默认宽度(您可以通过包括报告中的 card_width 数据来控制,这将在下面的 card_width 数据字段中返回 '200px' 或 '80%'。这两种方法都将支持属于卡 div 的 "style" 参数的值。例如 style='width: 200px' 或 style='width: 80%'。在这种情况下,您只需在 cardWidth 函数或下面的 card_width 数据字段中返回 '200px' 或 '80%'。

运行示例

为了测试您是否已正确安装,请使用 artisan 查看您的路由中是否有 Zermelo 卡的 URL。

./artisan route:list | grep ZermeloCard

您应该看到 3 个不同的路由...如果没有看到任何内容...则表示出了问题...

然后将示例数据和报告复制到您的安装中

mysqladmin -u YOURDBUSER -p create zermelo_cards
mysql -u YOURDBUSER -p zermelo_cards < vendor/careset/zermelobladecard/examples/data/zermelo_cards.sql
cp vendor/careset/zermelobladecard/examples/reports/CardTest.php app/Reports/

这将创建 zermelo_cards 测试数据库,用示例数据填充它...并将卡测试报告复制到您的安装中...

请记住,您需要确保您的 Laravel DB 用户对 zermelo_cards 数据库有 SELECT 权限。

然后,将您的浏览器指向

https://example.com/ZermeloCard/CardTest/

您应该看到内容

卡片语法

	//Card Layout Columns
        //this is based on the cards element from bootstrap https://bootstrap.ac.cn/docs/4.3/components/card/ in the standard view
        //card_header is text at the top card.
        //card_title will be the title of the card, inside the card content
        //card_text is beneath the title in the card content
        //card_img_top is the image url for an image placed at the top of the card
        //card_img_bottom is the image url for the bottom
        //card_img_top_alttext sets the alttext of the image at the top
        //card_img_bottom_alttext sets the alttext of the image at the bottom
        //card_footer is the text inside the footer of the card
	//card_body is any card-body content that will come after card-title, card-text
	//card_body_class is any additional css classes to control how the card-body div will act (the card-body div contains the card_title, card_text, and then anything you put into card_body
	//card_width the width of this card. If set will override the value from the cardWidth() function which can be used to set a default for the report... 

	//Card Block Layout Columns
	//card_layout_block_id this is any identifier you would like to use to label a sequential group of cards... by changing this for a sequential group 
	//	The cards will move to a new row (if they have not already) and they will switch between black text/white background to 
	//	white text on a grey background.. this is basically the same as the 'zebra' effect that is often used on. If this is not set, the cards 
	//	simply all use the black text/white background for all the cards...
	//card_layout_block_label this will be used as the heading before a new grouping of cards, if it is set.
	//card_layout_block_url if you have a block label, you can turn it into a link by setting this field..

        $sql = "
SELECT
        id AS card_header,
        title AS card_title,
        text AS card_text,
        image_url AS card_img_top,
        alt_text As card_img_top_altext,
        id AS card_footer
FROM zermelo_cards.cards
";