Skip to content

eddy7697/LaraFlash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flash Message For Laravel5

Build Status Scrutinizer Code Quality

介绍

基于 Jeffery Way's Flash Package

预览

1.gif 2.gif

安装

使用composer安装

composer require geekghc/flash

或者在你的composer.jsonrequire部分添加

"geekghc/flash":"~2.0"

下载完毕之后在config/app.php添加service provider

'providers' => [
    GeekGhc\LaraFlash\FlashProvider::class,
];

为了方便使用 可以再去添加一个alias

'aliases' => [
    'LaraFlash'=>GeekGhc\LaraFlash\Flash::class,
];

用法

在你的控制器里 重定向之前

public function store()
{
    LaraFlash::success("Welcome Aboard!");

    return Redirect::home();
}

在你的视图中添加notification视图

@include('laraflash::notification')

或者

@include('laraflash::header-notification')

你也可以按需求使用下面这种形式

  • LaraFlash::success('Message')
  • LaraFlash::info('Message')
  • LaraFlash::error('Message')
  • LaraFlash::warning('Message')

当然你可也以使用laraflash()这样的helper function

  • laraflash('Message!') 默认为info
  • laraflash()->success('Message!')
  • laraflash()->info('Message!')
  • laraflash()->error('Message!')
  • laraflash()->warning('Message!')

例子

在此之前使用CDN的形式引入jqueryfont-awesome

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Laravel</title>
    <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<script src="//cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
@include('laraflash::notification')
</body>
</html>

自定义样式

你可以修改样式以达到你的需求

php artisan vendor:publish

这样一来视图文件会放在你的resources/views/vendor/laraFlash目录下

About

Flash For Laravel 👏

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 57.5%
  • PHP 42.5%