定制 thomaswardiii/laravel-flash-foundation 二次开发

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

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

thomaswardiii/laravel-flash-foundation

最新稳定版本:1.3.5

Composer 安装命令:

composer require thomaswardiii/laravel-flash-foundation

包简介

Easy flash notifications in Laravel 5 for Foundation CSS 5

README 文档

README

Overview

This is a package forked from the Laracasts Flash package to provide Foundation CSS friendly flash messages. It is meant to be a drop-in replacement for Laracasts Flash.

Installation

First, pull in the package through Composer.

"require": {
    "thomaswardiii/laravel-flash-foundation": "~1.3"
}

And then, if using Laravel 5, include the service provider within app/config/app.php.

'providers' => [
    'Laracasts\Flash\FlashServiceProvider'
];

And, for convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'Flash' => 'Laracasts\Flash\Flash'
];

Usage

Within your controllers, before you perform a redirect...

public function store()
{
    Flash::message('Welcome Aboard!');

    return Redirect::home();
}

You may also do:

  • Flash::info('Message')
  • Flash::success('Message')
  • Flash::error('Message')
  • Flash::warning('Message')
  • Flash::overlay('Modal Message', 'Modal Title')

Again, if using Laravel, this will set a few keys in the session:

  • 'flash_notification.message' - The message you're flashing
  • 'flash_notification.level' - A string that represents the type of notification (good for applying HTML class names)

Alternatively, again, if you're using Laravel, you may reference the flash() helper function, instead of the facade. Here's an example:

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flash()->success('You have been logged out.');

    return home();
}

Or, for a general information flash, just do: flash('Some message');.

With this message flashed to the session, you may now display it in your view(s). Maybe something like:

@if (Session::has('flash_notification.message'))
    <div data-alert class="alert-box {{ Session::get('flash_notification.level') }}">
        {{ Session::get('flash_notification.message') }}
        <a href="#" class="close">&times;</a>
    </div>
@endif

Note that this package is optimized for use with ZURB Foundation.

Because flash messages and overlays are so common, if you want, you may use (or modify) the views that are included with this package. Simply append to your layout view:

@include('flash::message')

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="css/foundation.css">
</head>
<body>

<div class="container">
    @include('flash::message')

    <p>Welcome to my website...</p>
</div>

<script src="//code.jquery.com/jquery.js"></script>
<script src="js/foundation.min.js"></script>

<script>
    $(document).foundation();
</script>

<!-- This is only necessary if you do Flash::overlay('...') -->
<script>
    $('#flash-overlay-modal').modal();
</script>

</body>
</html>

If you need to modify the flash message partials, you can run:

php artisan vendor:publish

The two package views will now be located in the `app/views/packages/laracasts/flash/' directory.

Flash::message('Welcome aboard!');

return Redirect::home();

https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/message.png

Flash::error('Sorry! Please try again.');

return Redirect::home();

https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/error.png

Flash::overlay('You are now a Laracasts member!');

return Redirect::home();

https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/overlay.png

Learn exactly how to build this very package on Laracasts!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-24