Notifications (Toasr)
Panduan untuk menampilkan notifikasi dalam Nue UI
Built-in Toastr
Sederhananya, notifikasi ini maksudnya adalah untuk menginformasikan hasil dari proses yang bisa kamu kirim dari controllers atau routes. Nue sendiri menyediakan fitur Toastr bawaan, yaitu dengan contoh sebagai berikut:
/**
* Store a newly created resource in storage.
*
* @return mixed
*/
public function store(Request $request)
{
...
notify()->flash('Data berhasil disimpan.', 'success');
return redirect()->back();
}
Selain success
, juga tersedia warning
, info
, primary
dan danger
.
Build your own
Notify is front-end framework agnostic, so you're free to easily implement the output however you choose.
Options
You can pass additional options to the flash method, which are then easily accessible within your view.
notify()->flash('Welcome back!', 'success', [
'timer' => 3000,
'text' => 'It\'s really great to see you again',
]);
Then, in your view.
@if(notify()->ready())
<script>
swal({
title: "{!! notify()->message() !!}",
text: "{!! notify()->option('text') !!}",
type: "{{ notify()->type() }}",
@if (notify()->option('timer'))
timer: {{ notify()->option('timer') }},
showConfirmButton: false
@endif
});
</script>
@endif
The above example uses SweetAlert, but the flexibily of Notify means you can easily use it with any JavaScript alert solution.