keepeye / laravel-msgbox
一个漂亮的小工具,允许你在 Laravel 框架中显示信息框。
1.0.1
2014-12-28 04:27 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2024-09-24 03:24:55 UTC
README
Laravel 消息框
一个 Laravel 4.2 的包,允许你显示漂亮的页面消息,并能自动跳转到引用 URL 或你指定的 URL。
示例
<?php //this a test route Route::get("/test",function(){ return Msgbox::success('success tips..'); //return Msgbox::error('error tips...'); //return Msgbox::info('infomation...'); });
预览
安装
要求
php: >=5.4.0 laravel: v4.2
步骤1
composer require keepeye/laravel-msgbox:1.0.* --prefer-source
步骤2:将服务提供者添加到 app/config/app.php
'Keepeye\LaravelMsgbox\LaravelMsgboxServiceProvider',
步骤3:在 app/config/app.php
中设置别名
'Msgbox' => 'Keepeye\LaravelMsgbox\LaravelMsgboxFacade'
步骤4:可选配置
php artisan config:publish keepeye/laravel-msgbox php artisan view:publish keepeye/laravel-msgbox
因此,你可以修改配置文件 app/config/packages/keepeye/laravel-msgbox/config.php
中的配置参数,以及视图文件 app/views/packages/keepeye/laravel-msgbox/msg.php
。
使用方法
在你的控制器方法中,当你要显示消息时,可以返回如下
//by default,the page will auto jump to the $_SERVER['HTTP_REFERER'] return Msgbox::info("info text..."); //or you can specify the url ,for example: return Msgbox::info("info text...",URL::get('/login')); //you can specify the time like : return Msgbox::info("info text...",null,5);//after 5 second,it will jump to the referer url
默认时间基于包配置文件中定义的 default_timeout
。如果你不想自动跳转,只需将第三个方法参数设置为 0,或将配置参数 auto_jump
设置为 false
。此外,此方法和另外两种方法几乎相同
return Msgbox::success('...'); //and return Msgbox::error('...');