定制 sentix/alert 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sentix/alert

最新稳定版本:1.0.3

Composer 安装命令:

composer require sentix/alert

包简介

Laravel Alert Notification Plugin with configurable positions and colors

README 文档

README

A comprehensive Laravel plugin for displaying beautiful, configurable alert notifications with support for multiple positions, colors, and animations.

Features

  • Configurable Positions: Top, bottom, center with custom offsets
  • Multiple Color Themes: Success, error, warning, info, dark, light
  • Laravel Integration: Blade directives, facades, helper functions
  • Auto-dismiss: Configurable timeout with hover pause
  • Responsive Design: Mobile-friendly notifications
  • Session Integration: Automatic display of Laravel session messages
  • Validation Errors: Built-in support for Laravel validation errors

Installation

website: https://sentixtech.github.io/pluginAlert

  1. Install via Composer:
composer require sentix/alert
  1. Install NPM Dependencies:
npm install

2.3. Add Provider:

Alert\AlertNotificationServiceProvider::class
  1. Publish Configuration:
php artisan vendor:publish --provider="Alert\AlertNotificationServiceProvider" --tag="config"
  1. Publish Assets:
php artisan vendor:publish --provider="Alert\AlertNotificationServiceProvider" --tag="assets"

Usage

Blade Directives

Add these directives to your master layout file:

<!DOCTYPE html>
<html>
<head>
    <title>Your App</title>
    @alertStyles
</head>
<body>
    <!-- Your content -->

    @alertNotifications
    @alertScripts
</body>
</html>

Helper Functions

// In your controllers
session()->flash('success','Welcome to sentixtech.com');
session()->flash('error','Welcome to sentixtech.com');
session()->flash('info','Welcome to sentixtech.com');
session()->flash('warning','Welcome to sentixtech.com');

JavaScript Usage

// Show alerts programmatically
notify("success", "Dynamic success message");
notify("error", "Dynamic error message", "Custom Title");

// Legacy support
notify(false, "Success message"); // false = success
notify(true, "Error message"); // true = error

Configuration

Edit config/alert-notification.php to customize:

Position Settings

'position' => [
    'vertical' => 'bottom',   // top, bottom, center
    'horizontal' => 'right',  // left, right, center
    'offset' => [
        'top' => '20px',
        'bottom' => '20px',
        'left' => '20px',
        'right' => '20px',
    ]
],

Color Customization

'colors' => [
    'success' => [
        'background' => '#28a745',
        'text' => '#ffffff',
        'border' => '#1e7e34'
    ],
    // ... other colors
],

Animation Settings

'animation' => [
    'duration' => '0.35s',
    'easing' => 'cubic-bezier(0.21, 1.02, 0.73, 1)',
    'auto_dismiss' => true,
    'dismiss_timeout' => 5000, // milliseconds
],

Available Alert Types

  • success - Green success messages
  • error - Red error messages
  • warning - Yellow warning messages
  • info - Blue informational messages
  • dark - Dark themed messages
  • light - Light themed messages

Laravel Session Integration

The plugin automatically displays Laravel session messages:

// In your controller
return redirect()->back()->with('success', 'Data saved successfully!');
return redirect()->back()->with('error', 'Validation failed!');
return redirect()->back()->with('warning', 'Please review your input!');
return redirect()->back()->with('info', 'Additional information...');

Validation Errors

Validation errors are automatically displayed:

// In your controller
$request->validate([
    'email' => 'required|email',
    'name' => 'required|min:3'
]);
// Validation errors will automatically show as notifications

Advanced Configuration

Custom Icons

You can customize icons in the configuration file by modifying the icons array.

Progress Bar

Enable progress bar for auto-dismiss:

'enable_progress_bar' => true,
'progress_bar_height' => '4px',

Sound Notifications

'Coming Soon!!'

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

License

MIT License

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-20