sakanjo / laravel-flashy
Easy flash notifications for laravel
Fund package maintenance!
sakanjo
Requires
- php: >=6.0.0
This package is auto-updated.
Last update: 2024-12-27 23:27:11 UTC
README
A powerful package for creating flash messages in Laravel.
Installation
Require this package with composer using the following command
composer require sakanjo/laravel-flashy
Next publish the config file using the vendor:publish Artisan command
php artisan vendor:publish --provider="Flashy\ServiceProvider"
Usage
public function store(Request $request) { User::create([ 'name' => 'Salah Kanjo', 'email' => 'dev.salah.kanjo@gmail.com' ]); Success('Successfully created'); }
public function edit(Request $request) { Error_if(!auth()->user()->verified(), "Please verify your account first"); ... }
Or even a custom flash
Flash('info', 'Account requires verification', ['url' => 'http://example.org']);
Why
Imagine the next senario where you have a function inside another function and you want to return an error from the inner one all the way up
public function getData() { $user = Http::get('http://example.com/users/' . auth()->id); Error_if($user->failed(), 'Something went wrong'); return $user; }
public function index() { $data = getData(); // Stops execution here if user not found return inertia('Home', compact('data')) }
Support
Do you like this project? Support it by donating
Maintainers
Laravel flashy is developed and maintained by Salah Kanjo
License
Laravel flashy is open-sourced software licensed under the MIT license