Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liinkiing/flashr
A Laravel package made for displaying flashes messages in a conveniant way
https://github.com/liinkiing/flashr
composer flash laravel message pacakgist package
Last synced: about 3 hours ago
JSON representation
A Laravel package made for displaying flashes messages in a conveniant way
- Host: GitHub
- URL: https://github.com/liinkiing/flashr
- Owner: Liinkiing
- License: mit
- Created: 2017-04-21T09:24:13.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-21T13:27:03.000Z (almost 8 years ago)
- Last Synced: 2024-08-18T07:29:25.033Z (6 months ago)
- Topics: composer, flash, laravel, message, pacakgist, package
- Language: PHP
- Size: 14.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://github.com/laracasts/flash) package!#### Installation
Run
```
$ 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
```php
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
```php
'providers' => [
// ...\Linking\Flashr\FlashrServiceProvider::class,
];
```You should also add the Facade, in the file **app.php**, under the 'aliases' key, add
```php
'aliases' => [
// ..
'Flashr' => \Linking\Flashr\Facades\Flashr::class,
// ..
];```
#### Usage
Within your controllers, you can do
```php
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 :
* `Flashr::success($message)`
* `Flashr::info($message)`
* `Flashr::warning($message)`
* `Flashr::danger($message)`Then, in your views, you can include the vendor views, by doing
```blade
@include('flashr::flashes')
```> Note: it use, by default, the Twitter Bootstrap notation. If you want to replace this behaviour, just read what's next
If you want to customize the view, simply do
```
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 :```blade
@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)
{{ $flashr_message }}
×
@endif
```As you can see, the plugin add two keys in the session: `_flashr.type` and `_flashr.message`