承接 weboptic/laravel-flash-notifications 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

weboptic/laravel-flash-notifications

Composer 安装命令:

composer require weboptic/laravel-flash-notifications

包简介

Easy way to display Flash Notifications in Laravel 5.

README 文档

README

Flash Notifications Helper for Laravel 10

Install

Install via composer

Add dependency to your composer.json file and run composer update.

require: {
    "weboptic/laravel-flash-notifications": "1.0"
}

Configure Laravel

Add ServiceProvider and Alias (Facade) to your config/app.php file:

'Weboptic\Notifications\NotificationServiceProvider'
'Flash' => 'Weboptic\Notifications\Flash'

Include default alert view to your layout

Package default provides bootstrap ready alert view. Just include notifications::flash file to your main layout in blade:

@include('notifications::flash')

You can create own container for flash notifications with own custom styles. See Custom alert view section.

Usage

You can push flash message ever you need by facade Flash. It provides 4 alert types:

  • success
  • error
  • warning
  • info
Flash::info('Your alert message here!');

Every alert method takes 1 or 2 arguments. If you give one parameter it will be message. If you provide two parameters, first will be title and second will be message.

Flash::success('User has been updated successfully.');
Flash::error('Oh snap!', 'Something went wrong. Please try again for a few seconds.');

Custom alert view

Package default provides bootstrap ready view for alerts. You can define own style for it. Just create new blade template file!

@if(Session::has('flash.alerts'))
    @foreach(Session::get('flash.alerts') as $alert)

        <div class='alert alert-{{ $alert['level'] }}'>
            <button class="close" type="button" data-dismiss="alert" aria-hidden="true">&times;</button>

            @if( ! empty($alert['title']))
                <div><strong>{{ $alert['title'] }}</strong></div>
            @endif

            {{ $alert['message'] }}
        </div>

    @endforeach
@endif

All alerts will be in flash.alerts session variable. Single alert looks like:

[
  'title' => 'Title',
  'message' => 'Example message',
  'level' => 'success'
]

Level for all alerts are following:

  • Flash::success has level success
  • Flash::error has level danger
  • Flash::warning has level warning
  • Flash::info has level info

License

The MIT License. Copyright (c) 2014 - 2015 Szymon Krajewski.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-17