markwalet / nova-modal-response
这是一个用于在Laravel Nova动作中实现模态响应的Laravel Nova资源。
v0.3.0
2024-03-13 09:12 UTC
Requires
- php: ^7.4||^8.0
- laravel/framework: ^9.0|^10.0|^11.0
- laravel/nova: ^4.0
README
此包旨在简化在Laravel Nova中执行动作时使用自定义模态响应的过程。
关于此特定功能的更多信息,可以在Nova 文档中找到。
安装
composer require markwalet/nova-modal-response
使用方法
return Action::modal('modal-response', [ 'title' => 'Result in a model', 'body' => 'This is way better than that small notification in the bottom right!', ]);
当您需要渲染原始HTML时,可以使用html
参数代替
return Action::modal('modal-response', [ 'title' => 'Next steps', 'html' => '<ul><li>Show this package to your friends</li><li>Contribute</li><li>???</li><li>Profit!</li></ul>', ]);
还有一个专门的模式用于渲染代码片段。这将使用<pre>
和<code>
标签包围正文,但仍然启用转义
return Action::modal('modal-response', [ 'title' => 'The JSON response we got back from the external API', 'code' => json_encode($response->json(), JSON_PRETTY_PRINT), ]);
您还可以使用size
选项指定大小
return Action::modal('modal-response', [ 'title' => 'Test', 'body' => 'Lorem ipsum', 'size' => '7xl', ]);