Introduction
'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
6 là 1 package được sử dụng để tùy chọn hiêt thị các alert trên website.Package
6 chỉ hổ trợ từ phiên bản laravel 5.5 trở lên.'providers' => [ // Other service providers... RealRashid\SweetAlert\SweetAlertServiceProvider::class, ],
Install
Để cài đặt SweetAlert2 trong laravel, chúng ta sử dụng composer.
composer require realrashid/sweet-alert
Configuration
Sau khi cài đặt xong package, chúng ta phải đăng kí
'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
8 trong file 'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
9.'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
Thêm
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
0 facade vào 'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
1.'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
Thêm thư viện 'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
2 vào layout
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
Install thư viện javascript
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
3 băng npmnpm i sweetalert2
hoặc sử dụng link cdn
Trong file master layout của bạn, import thư viện
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
3.
Sau đó include sweetalert view.
@include['sweetalert::alert']
Usage
Sử dụng 'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
5
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
Đầu tiên bạn phải import Alert Facade,
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
6 or 'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
7 trong controller.Alert::alert['Title', 'Message', 'Type'];
Alert::success['Success Title', 'Success Message'];
Alert::info['Info Title', 'Info Message'];
Alert::warning['Warning Title', 'Warning Message'];
Alert::error['Error Title', 'Error Message'];
Alert::question['Question Title', 'Question Message'];
Alert::html['Html Title', 'Html Code', 'Type'];
Alert::toast['Toast Message', 'Toast Type', 'Toast Position'];
Sử dụng hàm 'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
8
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
Alert
alert['Title','Lorem Lorem Lorem', 'success'];
alert[]->success['Title','Lorem Lorem Lorem'];
alert[]->info['Title','Lorem Lorem Lorem'];
alert[]->warning['Title','Lorem Lorem Lorem'];
alert[]->question['Title','Lorem Lorem Lorem'];
alert[]->error['Title','Lorem Lorem Lorem'];
alert[]->html['HTML example'," You can use bold text, links and other HTML tags ",'success'];
Toast
toast['Your Post as been submited!','success','top-right'];
Demo
Success Alert & Success Error
Hiển thị thông báo khi tạo 1 post thành công hoặc thất bại.
'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
0Methods Definition
9'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
1Hàm này có 2 đối số truyền vào:
0: giá trị mặc định là true, cài đặt hiển thị buttom comfirm.npm i sweetalert2
1 mặc định là false, cài đặt hiển thị buttom close.npm i sweetalert2
2npm i sweetalert2
'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
2Đối số
npm i sweetalert2
3 có giá trị mặc định 5000, set tự động ẩn alert. npm i sweetalert2
4 npm i sweetalert2
5 npm i sweetalert2
6npm i sweetalert2
4 npm i sweetalert2
5 npm i sweetalert2
6'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
3Config button confirm, cancel, close.
7npm i sweetalert2
'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
4Import code html vào footer của alert.
8npm i sweetalert2
npm i sweetalert2
9 mặc định: 'top-right'.'providers' => [
// Other service providers...
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],
5Một vài hình ảnh demo
Các bạn có thể tham khảo chi tiết tại //github.com/realrashid/sweet-alert