PHP code example of thbappy7706 / laravel-toastify
1. Go to this page and download the library: Download thbappy7706/laravel-toastify 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/ */
thbappy7706 / laravel-toastify example snippets
use Toastify\Laravel\Facades\Toastify;
public function store(Request $request)
{
// Your logic here
Toastify::success('User created successfully!');
return redirect()->route('users.index');
}
// Other types
Toastify::error('Something went wrong!');
Toastify::warning('Please check your input!');
Toastify::info('New update available!');
Toastify::default('This is a toast message');
use Toastify\Laravel\Facades\Toastify;
class UserForm extends Component
{
public function save()
{
// Your logic here
$this->dispatch('toast:add', toast: [
'type' => 'success',
'message' => 'Data saved successfully!'
]);
}
}
Toastify::success('Custom toast!', [
'autoClose' => 3000, // Auto close after 3 seconds
'position' => 'bottom-right', // Position
'transition' => 'slide', // Animation type
'hideProgressBar' => false, // Show progress bar
'pauseOnHover' => true, // Pause on hover
'draggable' => true, // Enable drag to dismiss
'closeButton' => true, // Show close button
'rtl' => false, // Right-to-left
]);