Laravel Toastr is a simple and elegant notification package for Laravel applications. It integrates the popular Toastr.js library, allowing you to display stylish and customizable toast notifications in your Laravel project with minimal effort.
- Installation
- Configuration
- Usage
- Customization
- Contributing
- License
- Run the following command to install the package:
composer require awalhadi/laravel-toastr
- If you want to customize the default configuration, you can publish the assets and configuration file:
php artisan vendor:publish --provider="AwalHadi\LaravelToastr\ToastrServiceProvider"
After publishing, you can customize the Toastr options by editing the config/toastr.php file.
Use the Toastr facade to add Toastr notifications in your controllers:
use Toastr;
public function updateProfile(Request $request)
{
// Update the user's profile...
Toastr::showSuccess('Profile updated successfully!');
return redirect()->route('profile');
}
Include the Toastr assets and display the notifications by using the** @h_toastr** directive in your Blade views:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Other head elements... -->
</head>
<body>
<!-- Body elements... -->
@h_toastr
</body>
</html>
You can customize the appearance and behavior of the Toastr notifications by editing the config/toastr.php file.
Contributions are welcome! Please read the contributing guide to learn how to contribute to this project.
Laravel Toastr is open-sourced software licensed under the MIT license.