takshak/alertt

Laravel 警报

1.0.4 2022-02-02 18:33 UTC

This package is auto-updated.

Last update: 2024-09-04 13:45:25 UTC


README

此包包含HTML、CSS和一些JS代码行,可以用于在前端显示通知/警报。它不需要任何CSS框架,如Bootstrap、Materialize等。

快速开始

使用以下命令将包导入您的项目

composer require takshak/alertt

您可以使用辅助函数或外观进行使用

alertt()->info('Your notification message goes here');

通过Alertt外观

\Alertt::info('Your notification message goes here');

您还可以在重定向时设置参数

return redirect('any/url')->withInfo('Your notification message goes here');

OR

return to_route('any/url')->withErrors('Your error message goes here');

要显示alertt框,您需要在布局或任何所需的blade文件中添加<x-alertt-alert />组件。

可用方法

通过外观和辅助函数的alertt示例片段。所有函数不一定需要调用。您可以设置自己的默认值,只需传递消息。

\Alertt::title('You have a new notification')
	    ->info('Content of message goes here')
	    ->footer('link of the target page')
	    ->timeout(6000);
// or
alert()->title('You have a new notification')
	    ->info('Content of message goes here')
	    ->footer('link of the target page')
	    ->timeout(6000);

您可以在不使用alertt()或\Alertt的情况下设置重定向期间的参数。您需要通过前缀'with'链接所有函数,例如:withSuccess()、withTitle()、withFooter()等。示例

return redirect()->route('name.of.route')
			->withTitle('You have a new notification')
		    ->withSuccess('Content of message goes here')
		    ->withFooter('link of the target page')
		    ->withTimeout(6000);

设置默认值

要设置默认标题、页脚消息、默认超时、位置等,您可以通过配置文件设置。或者在需要更改HTML / CSS代码的情况下,您将在resources/views/components/alertt.blade.php中找到blade文件。首先,发布配置文件或视图文件或两者,然后尝试设置您的值。

您可以从配置文件中更改位置、字体大小、颜色和其他内容。