Paket ringan untuk mengirim pesan flash dalam aplikasi Laravel. Paket ini hanya mendukung satu pesan flash tunggal pada satu waktu, dan pesan flash ditampilkan dalam format pemberitahuan roti panggang
composer require bkstar123/flashing
Setelah itu, Anda perlu mempublikasikan aset paket:
php artisan vendor:publish --provider="Bkstar123FlashingFlashingServiceProvider"
Ini akan menyalin elemen tampilan blade ke resources/views/vendor/bkstar123_flashing/flashing.blade.php . Anda bebas untuk menyesuaikan elemen tampilan ini. Juga, itu akan menyalin file JavaScript paket ke public/js/vendor/bkstar123)handling/*.js
a) dalam tampilan
Dalam tata letak tampilan atau master, cukup sertakan elemen tampilan paket dengan @include('bkstar123_flashing::flashing')
b) dalam metode pengontrol
Di luar kotak, paket memberi Anda alat berikut untuk mem -flash sebuah pesan:
Bkstar123FlashingFacadesFlashing fasad. Atau, Anda dapat menggunakan aliasnya Flashingflashing()Paket mendukung jenis -jenis pesan berkedip berikut:
Contoh :
<?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 (); Semua metode success() | error() | warning() | info() dapat dirantai setelah message() serta dirantai oleh important(), timeout() & position() . Di final, Anda harus selalu menambahkan flash() ke rantai.
Catatan : flashing('hello world') <=> Flashing::message('hello world')