moataz/notify 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moataz/notify

Composer 安装命令:

composer require moataz/notify

包简介

A site notification package for laravel.

README 文档

README

A site notification package for laravel.

Currently let's you easily flash notifications to the session. It also supports laravels translation package out of the box.

Table of Contents

Installation

You can install the package for your Laravel project through Composer.

# Laravel 4x
composer require andheiberg/notify:1.*

# Laravel 5x
composer require andheiberg/notify:2.*

Register the service provider in app/config/app.php.

Andheiberg\Notify\NotifyServiceProvider::class,

Add the alias to the list of aliases in app/config/app.php.

'Notify' => Andheiberg\Notify\Facades\Notify::class,

Configuration

The packages provides you with some configuration options.

To create the configuration file run this command in your command line app:

# Laravel 4x
php artisan config:publish andheiberg/notify

# Laravel 5x
php artisan vendor:publish --provider="Andheiberg\Notify\NotifyServiceProvider"

The configuration file will be published here: app/config/packages/andheiberg/notify/config.php.

Usage

Adding Notifications

By default, the package has some notification types defined in its configuration file. The default types are success, error, warning and info.

Every type can be called as a function.

Notify::info('This is an info message.');
Notify::error('Whoops, something has gone wrong.');

You can of course add your own types by adding them to your own config file. See above on how to publish the config file.

You can also pass a language tag for easy localization.

Notify::success('auth.login-successful'); // Calls Lang::get('auth.login-successful') behind the scene
Notify::warning('auth.verification-email-sent', ['email' => 'test@gmail.com']) // You can also pass replacements

Displaying Notifications

Notify class is just an extension of Illuminate's MessageBag class, which means we can use all of its functionality to display messages.

@foreach (Notify::all() as $notification)
    {{ $notification }}
@endforeach

Or if you'd like to display a single notification for a certain level.

@if (Notify::has('success'))
    {{ Notify::first('success') }}
@endif

If you'd like to learn more ways on how you can display messages, please take a closer look to Illuminate's MessageBag class.

Bootstrap example

@if (Notify::all())
	<div class="container">
		@foreach (Notify::get('success') as $alert)
			<div class="alert alert-success">
				<button type="button" class="close" data-dismiss="alert">&times;</button>
				{{ $alert }}
			</div>
		@endforeach

		@foreach (Notify::get('error') as $alert)
			<div class="alert alert-danger">
				<button type="button" class="close" data-dismiss="alert">&times;</button>
				{{ $alert }}
			</div>
		@endforeach

		@foreach (Notify::get('info') as $alert)
			<div class="alert alert-info">
				<button type="button" class="close" data-dismiss="alert">&times;</button>
				{{ $alert }}
			</div>
		@endforeach

		@foreach (Notify::get('warning') as $alert)
			<div class="alert alert-warning">
				<button type="button" class="close" data-dismiss="alert">&times;</button>
				{{ $alert }}
			</div>
		@endforeach
	</div>
@endif

统计信息

  • 总下载量: 178
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-10-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固