Laravelアプリケーションでフラッシュメッセージを送信するための軽量パッケージ。このパッケージは一度に1つのフラッシュメッセージのみをサポートし、フラッシュメッセージはトースト通知の形式で表示されます
composer require bkstar123/flashing
その後、パッケージの資産を公開する必要があります。
php artisan vendor:publish --provider="Bkstar123FlashingFlashingServiceProvider"
ブレードビュー要素をアプリケーションのresources/views/vendor/bkstar123_flashing/flashing.blade.phpにコピーします。このビュー要素を自由にカスタマイズできます。また、パッケージのJavaScriptファイルをアプリケーションのpublic/js/vendor/bkstar123)handling/*.js
a)視界
ビューまたはマスターレイアウトでは、 @include('bkstar123_flashing::flashing')にパッケージのビュー要素を含めるだけです。
b)コントローラー方法
箱から出して、パッケージはメッセージをフラッシュするための次のツールセットを提供します。
Bkstar123FlashingFacadesFlashing Facade。または、そのエイリアスFlashingを使用することもできますflashing()ヘルパー関数パッケージは、次の種類の点滅メッセージをサポートしています。
例:
<?php
// Flash a info-typed message by default
Flashing:: message ( ' Welcome to the home page ' )
-> flash ();
flashing ( ' Welcome to the home page ' )
-> flash ();
// Flash a success-typed message
Flashing:: message ( ' Welcome to the home page ' )
-> success ()
-> flash ();
flashing ( ' Welcome to the home page ' )
-> success ()
-> flash ();
// Flash a message and mark it as important i.e it will not disappear until being dismissed by yourself
Flashing:: message ( ' Important message ' )
-> important ()
-> flash ();
flashing ( ' Important message ' )
-> important ()
-> flash ();
// Specify the miliseconds for timing out the flash message
// The given timeout will be ignored if you mark the flash message as important
Flashing:: message ( ' This message will disappear after 3 seconds ' )
-> timeout ( 3000 )
-> flash ();
flashing ( ' This message will disappear after 3 seconds ' )
-> timeout ( 3000 )
-> flash ();
// Specify the location of the flash message, it can be either top-right or bottom-right
Flashing:: message ( ' I will be on the top-right of your screen ' )
-> position ( ' top ' )
-> flash ();
flashing ( ' I will be on the top-right of your screen ' )
-> position ( ' top ' )
-> flash ();すべての方法success() | error() | warning() | info() message()の後にチェーンを変更し、 important(), timeout() & position()によってチェーンされます。ファイナルでは、常にflash()チェーンに追加する必要があります。
注: flashing('hello world') <=> Flashing::message('hello world')