ez-laravel/flash-messages
Composer 安装命令:
composer require ez-laravel/flash-messages
包简介
Easy flash messages for your Laravel application.
README 文档
README
Package to provide you with an easy way to implement flash messages in your Laravel application.
Installation
Run the following command in your project directory to install the package:
composer require ez-laravel/flash-messages
Publish the vue components using the following commands:
php artisan vendor:publish --provider=EZ\FlashMessages\FlashServiceProvider --tag=vue
This will publish a flash-messages directory in your resources/js/components directory.
Make sure these components are (auto) loaded in. I usually make this happen using:
// app.js // Automatically load all vue components const files = require.context('./', true, /\.vue$/i); files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));
To be able to render the 'important' icon this package makes use of Font Awesome icons so make sure that's loaded if you intend to use the 'important' status
Usage
Use the following blade directive to include the flash messages partial in any view you'd like to display flash messages in
@include("flash::messages")
Afterwards you can call the following methods from your controller to flash messages to the session which will be displayed on the next page load.
// Message with level 'info' flash('Your message'); // Message with level 'success' flash('Your message')->success(); // Message with level 'error' flash('Your message')->error(); // Message with level 'warning' flash('Your message')->warning(); // Overlay (modal) with default title and custom message flash('Your message')->overlay(); // Overlay (modal) with custom title and message flash()->overlay('Your message', 'Your title'); // Message with level 'info' which is important (so it gets a warning icon) flash('Your message')->important();
Flash message partial
If you'd like to customize the flash message partial you can publish it using the following command:
php artisan vendor:publish --provider=EZ\FlashMessages\FlashServiceProvider --tag=views
This will publish the partial to the resources/views/vendor/flash directory.
Customize styling
All styling is defined inside of the vue components you've published.
To do
- Add an option to automatically hide the flash message after X seconds
Credits
This package was basically copied from laracasts/flash as a practice project. I used to use that package a lot and this one is custom tailored to how I like to use it. So big thank you to laracasts for the code and all lessons provided by their platform.
ez-laravel/flash-messages 适用场景与选型建议
ez-laravel/flash-messages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ez-laravel/flash-messages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ez-laravel/flash-messages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-20