定制 jambasangsang/flash 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

jambasangsang/flash

Composer 安装命令:

composer require jambasangsang/flash

包简介

This package will send flash notification to your application

README 文档

README

Issues Latest Version License Stars Total Downloads

Laravel Flash Notification

Flash Notification Types:

Laravel Flash Notification

Installation

Quick Installation using composer.

Run:

 composer require jambasangsang/flash

Then you can add the service provider to config/app.php.

In Laravel versions 5.6 and beyond, this step can be skipped if package auto-discovery is enabled.

'providers' => [
    Jambasangsang\Flash\FlashNotificationServiceProvider::class,
];

Publish the configuration file:

php artisan vendor:publish --provider='Jambasangsang\Flash\FlashNotificationServiceProvider' --tag="flash-config"

If not found run the below command:

 php artisan vendor:publish 

And select Jambasangsang\Flash\FlashNotificationServiceProvider

Usage

1. If your application is using jQuery do not include [@jQuery], Otherwise Add the below code in your main view template:

CSS @flashStyle,

JS @jQuery, @flashScript, @flashRender

Example:

<!-- layouts/app.blade.php -->

<!doctype html>
<html>
    <head>
        
        @flashStyle
    </head>

    <body>
        
    @jQuery
    @flashScript
    @flashRender

    </body>
</html>

2. Within your controllers, before you perform a redirection...

Example:

<?php

namespace App\Http\Controllers;

use App\Http\Requests\LevelStoreRequest;
use App\Models\Level;
use Illuminate\Http\RedirectResponse;
use App\Jambasangsang\Services\Levels\LevelService;
use Jambasangsang\Flash\Facades\LaravelFlash;

class LevelController extends Controller
{

    public function store(LevelStoreRequest $request, LevelService $levelService): RedirectResponse
    {
       
       try{
            $levelService->storeLevelData(new Level(), $request);

            LaravelFlash::withSuccess("Level added successfully!");

       }catch{

            LaravelFlash::withError("Woops!! an error check your input and try again!");
       }
        
        return redirect()->route('levels.index');
    }
}

You may also use other options below:

  • LaravelFlash::withInfo('You have pay your bills this week!')
  • LaravelFlash::withSuccess('Your Record has been saved successfully!')
  • LaravelFlash::withWarning('You have an security issue try to fix that!')
  • LaravelFlash::withError('Your Record was not saved Fail!')

configuration:

to customize your flash notification.
// config/flash.php
<?php

return [

    'options' => [
        'message'       => 'Default Message Here', //String
        'messageTextColor'   => '#ffff', //String
        'position'        => 'top-right', //String
        'customClass'     => '', //String
        'width'       => 'auto', //String Ex. 190px etc.
        'showCloseButton'         => true, //Boolean
        'closeButtonText'       => 'Close', //String
        'alertScreenReader'      => true, //Boolean
        'duration'       => 5000,
        'onClose'        => 'el', // Write your custom function here
        'closeButtonTextColor'      => '#FFFF',
    ],
];

Credits

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固