carkii / notifier
This package is not auto-updated.
Last update: 2024-09-19 04:00:16 UTC
README
Notifier 是一个 Laravel 库,帮助您向注册用户弹出通知。
要求
1- Jquery
如何安装?
- Composer:输入
composer require carkii/notifier
配置(提供者 & 别名)
在 config\app.php
中,添加 notifier 服务提供者
'providers' => [ /* // other providers // */ Carkii\Notifier\NotifierServiceProvider::class, ]
并将别名添加到同一文件
'aliases' => [ /* // other aliases // */ 'Notifier' => Carkii\Notifier\facades\Notifier::class, ]
发布
在终端中输入 php artisan vendor:publish
发布所需的文件。
这将向您的项目添加以下内容
1- /config/notifier.php
2- /resources/views/notifications/_cardExample.blade.php
3- /resources/views/notifications/_ModalExample.blade.php
4- /public/css/notifications.css
5- /public/js/notifications.js
迁移 notifications
表
在您的终端中,输入:php artisan migrate
注意:此库假设您已经迁移了数据库中名为 users
的用户表。
添加 CSRF_token
将 CSRF_token 添加到您的 head 标签中,在 html 标签中添加:php <meta name="csrf-token" content="{{ csrf_token() }}">
如何使用?
1- 模态框(弹出窗口)
1- 登录您的网站
2- 在您的页面末尾添加以下内容(默认:app.blade.php)
{!! Notifier::break(0,30,0)->get()->first() !!} {!! Notifier::addStylesAndScriptes() !!}
3- 将 /resources/views/notifications/_ModalExample.blade.php
中的第一个下划线 (_) 删除,变为 /resources/views/notifications/ModalExample.blade.php
。 (此示例使用 Bootstrap)
注意
- break($days,$hours,$minutes) is used to add a break time between notifications.
- the first underscore of your notification file tells Notifier to ignore this file.
- All of your notifications are located in ```/resources/views/notifications/```, each notification in each file (blade template) So, whenever you add a file to this folder, it means you are adding a new notification to your list.
4- 访问您的网站:)
2- 卡片(通知列表)
1- 登录您的网站
2- 在您的页面中添加以下内容(默认:app.blade.php,建议在导航栏中)
// get list of notifications and diaply them as a list // navbar <nav class="navbar navbar-inverse"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Notifications @if(Notifier::count()) <span class="badge background-myred notifications-counter">{{Notifier::count()}}</span> @endif <i class="fa fa-bell" aria-hidden="true"></i> <span class="caret"></span> </a> <ul class="dropdown-menu"> @if(Notifier::any()) @foreach(Notifier::get() AS $notification ) <li>{!! $notification !!}</li> @endforeach @else <li class='text-center' >No Notifications</li> @endif </ul> </li> </nav> //end of navbar //end of your page's body {!! Notifier::addStylesAndScriptes() !!}
3- 将 /resources/views/notifications/_CardExample.blade.php
中的第一个下划线 (_) 删除,变为 /resources/views/notifications/CardExample.blade.php
。 (此示例使用 Bootstrap)
4- 访问您的网站:)