2017 © Pedro Peláez
 

library flashr

A Laravel package made for displaying flashes messages in a conveniant way

image

linking/flashr

A Laravel package made for displaying flashes messages in a conveniant way

  • Friday, April 21, 2017
  • by Linking
  • Repository
  • 1 Watchers
  • 2 Stars
  • 396 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

, (*1)

Flashr

A laravel package which make printing flashes a breeze!

Introduction

This is my first ever package published. I wanted to learn how to make a simple package for Laravel. I've been reading a lot about the IoC container, how Laravel does the dependency injection etc... This package was inspired by the great laracasts/flash package!, (*2)

Installation

Run, (*3)

$ composer require linking/flashr

When the package is installed, if you're running Laravel 5.x, you can register the package in the AppServiceProvider, like this, (*4)

<?php
        use Linking\Flashr\FlashrServiceProvider;
        use Illuminate\Support\ServiceProvider;

        class AppServiceProvider extends ServiceProvider
        {
            /**
             * Bootstrap any application services.
             *
             * @return void
             */
            public function boot()
            {
                // ...
                $this->app->register(FlashrServiceProvider::class);
            }

        }

If you're running an older version of Laravel, you can edit the app.php file, and add this in the providers option, (*5)

    'providers' => [

        // ...

         \Linking\Flashr\FlashrServiceProvider::class,

    ];

You should also add the Facade, in the file app.php, under the 'aliases' key, add, (*6)


'aliases' => [ // .. 'Flashr' => \Linking\Flashr\Facades\Flashr::class, // .. ];

Usage

Within your controllers, you can do, (*7)

public function edit(Post $post) {
    Flashr::success("The post has been edited");
    return view('post.edit', compact('post'));
}

Flashr expose differents functions to print different type of flashes. Here is a list of Flashr functions :, (*8)

  • Flashr::success($message)
  • Flashr::info($message)
  • Flashr::warning($message)
  • Flashr::danger($message)

Then, in your views, you can include the vendor views, by doing, (*9)

@include('flashr::flashes')

Note: it use, by default, the Twitter Bootstrap notation. If you want to replace this behaviour, just read what's next, (*10)

If you want to customize the view, simply do, (*11)

php artisan vendor:publish --tag=flashr

then, go tho your views directory. You should find a vendor directory. Inside this directory, a flashr directory will be here. You can edit this file to whatever you want. By default, the file looks like this :, (*12)

@php
    $flashr_type = Session::has('_flashr.type') ? Session::get('_flashr.type') : null;
    $flashr_message = Session::has('_flashr.message') ? Session::get('_flashr.message') : null;
@endphp

@if($flashr_type && $flashr_message)

    <div style="position: relative" class="alert alert-{{ $flashr_type }}" role="alert">
        {{ $flashr_message }}
        <span id="close-flash" onclick="var el = this.parentElement; el.remove()"
              style="position: absolute; top: 10px; right: 10px; font-size: 24px; line-height: 10px; cursor: pointer">&times;</span>
    </div>

@endif

As you can see, the plugin add two keys in the session: _flashr.type and _flashr.message, (*13)

The Versions

21/04 2017

dev-master

9999999-dev

A Laravel package made for displaying flashes messages in a conveniant way

  Sources   Download

The Requires

  • php >=5.4.0

 

The Development Requires

by Omar Jbara

laravel messages flash flash messages liinkiing

21/04 2017

v1.0.1

1.0.1.0

A Laravel package made for displaying flashes messages in a conveniant way

  Sources   Download

The Requires

  • php >=5.4.0

 

The Development Requires

by Omar Jbara

laravel messages flash flash messages liinkiing