แพ็คเกจน้ำหนักเบาเพื่อส่งข้อความแฟลชในแอปพลิเคชัน Laravel แพ็คเกจนี้รองรับข้อความแฟลชเพียงครั้งเดียวในแต่ละครั้งและข้อความแฟลชจะแสดงในรูปแบบของการแจ้งเตือนขนมปังปิ้ง
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')