binary-cats/shoutout 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

binary-cats/shoutout

最新稳定版本:1.1.0

Composer 安装命令:

composer require binary-cats/shoutout

包简介

An inspirational title for your toasts

README 文档

README

Shoutout

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Inspirational titles for your toasts.

Ever got stuck writing another title for your success toast? Ever got bored with "Success!" message? Shoutout solves this for you with random configurable messages

Installation

composer require binary-cats/shoutout

You can publish the config file with:

php artisan vendor:publish --tag=shoutout-config

This will create config/shoutout.php where you can customize the titles for each notification type. This is the contents of the published config file:

return [

    /*
    |--------------------------------------------------------------------------
    | Default Message Type
    |--------------------------------------------------------------------------
    |
    | The default message type to use when calling Shoutout::random() without
    | specifying a type. Supported: "info", "success", "warning", "danger", "error"
    |
    */

    'default' => 'info',

    /*
    |--------------------------------------------------------------------------
    | Messages
    |--------------------------------------------------------------------------
    |
    | These titles will be randomly selected for toast notifications based
    | on their type. Feel free to customize these to match your app's tone.
    |
    */

    'messages' => [
        'info' => [
            'Just so you know...',
            'A quick heads-up',
            'No alarms, just info',
            'Keeping you in the loop',
            'For your consideration',
            'Minor detail, major impact',
            'Logged and loaded',
            'Nothing urgent',
            'All part of the plan',
            'Thought you might like to know',
            'Friendly little update',
        ],
        'success' => [
            'Achievement unlocked!',
            'Flawless execution',
            'Great success!',
            'Huzzah!',
            'Like a boss',
            'Nice!',
            'Smooth as butter!',
            'That\'s how it\'s done!',
            'Very nice!',
            'Victory dance initiated',
            'We made it!',
            'Well done!',
        ],
        'warning' => [
            'Watch out',
            'Careful now',
            'Hmm...',
            'Warning',
            'Hold up',
            'Attention',
            'Heads up',
        ],
        'danger' => [
            'Oh well',
            'Not good',
        ],
        'error' => [
            'Oops',
            'Oh no',
            'Yikes',
            'Error',
            'So sad',
            'Uh oh!',
        ],
    ],
];

Usage

Shoutout comes in two flavors. You can use a Shoutout facade or a shoutout() helper method:

use BinaryCats\Shoutout\Facades\Shoutout;

// Get a random title using the default type (configured in config)
$title = Shoutout::random();   // Uses 'info' set by default

// Get random titles by specific type
$successTitle = Shoutout::success();  // "Achievement unlocked!", "Nice!", etc.
$infoTitle = Shoutout::info();        // "Just so you know...", "A quick heads-up", etc.
$warningTitle = Shoutout::warning();  // "Watch out", "Careful now", etc.
$dangerTitle = Shoutout::danger();    // "Oh well", "Not good"
$errorTitle = Shoutout::error();      // "Oops", "Oh no", etc.

Example with Toast Notifications

// In a Controller
public function store(Request $request): RedirectResponse
{
    // ... save logic

    return redirect()
        ->route('posts.index')
        ->with('toast', [
            'type' => 'success',
            'title' => Shoutout::success(),
            'message' => 'Post created successfully!'
        ]);
}

or with Livewire Flux:

    Flux::toast(
        heading: Shoutout::success(),
        text: 'Your changes have been saved.',
        variant: 'success',
    );

.. you get the idea.

Testing

Shoutout provides a test fake:

use BinaryCats\Shoutout\Facades\Shoutout;

public function test_it_shows_success_toast(): void
{
    Shoutout::fake()
        ->expect('success')
        ->andReturn('Test Success');

    $response = $this->post('/posts', ['title' => 'Test']);

    $response->assertSessionHas('toast.title', 'Test Success');
}

You can chain fake expectations:

Shoutout::fake()
    ->expect('success')->andReturn('Yay!')
    ->expect('danger')->andReturn('Oh no!')
    ->expect('error')->andReturn('Failed!');

If no expectation is set for a method, the fake will return a random value from config (same as the real implementation).

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

Support us

Binary Cats is a webdesign agency based in Illinois, US.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固