awalhadi/laravel-toastr

v1.0.0 2023-08-10 00:51 UTC

This package is auto-updated.

Last update: 2024-04-24 18:04:50 UTC


README

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.

Table of Contents

  • Installation
  • Configuration
  • Usage
  • Customization
  • Contributing
  • License

Installation

  1. Install the Package

    Run the following command to install the package:
composer require awalhadi/laravel-toastr
  1. Publish Assets and Configuration (Optional)

    If you want to customize the default configuration, you can publish the assets and configuration file:
php artisan vendor:publish --provider="AwalHadi\LaravelToastr\ToastrServiceProvider"

Configuration

After publishing, you can customize the Toastr options by editing the config/toastr.php file.

Usage

In Controllers

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');
}

In Views

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>

Customization

You can customize the appearance and behavior of the Toastr notifications by editing the config/toastr.php file.

Contributing

Contributions are welcome! Please read the contributing guide to learn how to contribute to this project.

License

Laravel Toastr is open-sourced software licensed under the MIT license.