PHP code example of shufflingpixels / laravel-toast
1. Go to this page and download the library: Download shufflingpixels/laravel-toast library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shufflingpixels / laravel-toast example snippets
use ShufflingPixels\Toast\Toast;
public function store()
{
Toast::success('Saved successfully');
return view('profile');
}
use Toast;
public function update()
{
Toast::success('Profile updated')->flash();
return redirect()->route('profile.show');
}
use ShufflingPixels\Toast\Severity;
// Get the manager and add messages fluently
toast()->info('Heads up');
toast()->success('Saved', 'All changes are synced', 5000);
// Create immediately via helper (one-liner)
toast(Severity::ERROR, 'Something went wrong', 'Please try again');
// Flash a specific message for the next request
toast()->warning('Requires attention')->flash();
function toast(?Severity $severity = null, ?string $text = null, ?string $details = null, int $duration = 3000): \ShufflingPixels\Toast\Manager
use ShufflingPixels\Toast\Toast;
// Create messages (returns Message)
Toast::info(string $text, ?string $details = null, int $duration = 3000);
Toast::success(string $text, ?string $details = null, int $duration = 3000);
Toast::warning(string $text, ?string $details = null, int $duration = 3000);
Toast::error(string $text, ?string $details = null, int $duration = 3000);
Toast::new(Severity $severity, string $text, ?string $details = null, int $duration = 3000);
// Flash a single message to session
Toast::flash(\ShufflingPixels\Toast\Message $message): void;
// Retrieve all messages for the current request
Toast::getMessages(): Illuminate\Support\Collection<int, \ShufflingPixels\Toast\Message>;
// Retrieve flashed messages without merging
Toast::getFlashMessages(): Illuminate\Support\Collection<int, \ShufflingPixels\Toast\Message>;