PHP code example of arnoldwamae / livewire-alert
1. Go to this page and download the library: Download arnoldwamae/livewire-alert library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arnoldwamae / livewire-alert example snippets
use Jantinnerezo\LivewireAlert\LivewireAlert;
class Index extends Component
{
use LivewireAlert;
public function submit()
{
$this->alert('success', 'Basic Alert');
}
}
$this->alert('success', 'Success is approaching!');
$this->alert('warning', 'The world has warned you.');
$this->alert('info', 'The fact is you know your name :D');
$this->alert('question', 'How are you today?');
$this->alert('info', 'This is not as toast alert', [
'toast' => false
]);
$this->alert('info', 'Centering alert', [
'position' => 'center'
]);
$this->alert('question', 'How are you today?', [
'showConfirmButton' => true
]);
$this->alert('question', 'How are you today?', [
'showConfirmButton' => true,
'confirmButtonText' => 'Good'
]);
public function confirmed()
{
// Do something
}
protected $listeners = [
'confirmed'
];
public function getListeners()
{
return [
'confirmed'
];
}
$this->alert('question', 'How are you today?', [
'showConfirmButton' => true,
'confirmButtonText' => 'Good',
'onConfirmed' => 'confirmed'
]);
$this->alert('warning', 'Please enter password', [
'showConfirmButton' => true,
'confirmButtonText' => 'Submit',
'onConfirmed' => 'confirmed',
'input' => 'password',
'inputValidator' => '(value) => new Promise((resolve) => '.
' resolve('.
' /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+=!*()@%&]).{8,}$/.test(value) ?'.
' undefined : "Error in password"'.
' )'.
')',
'allowOutsideClick' => false,
'timer' => null
]);
public function confirmed($data)
{
// Get input value and do anything you want to it
$password = $data['value'];
}
public function denied()
{
// Do something when denied button is clicked
}
public function cancelled()
{
// Do something when cancel button is clicked
}
public function getListeners()
{
return [
'denied',
'dismissed'
];
}
$this->alert('warning', 'Alert with deny and cancel button', [
'showDenyButton' => true,
'denyButtonText' => 'Deny',
'showCancelButton' => true,
'cancelButtonText' => 'Cancel',
'onDenied' => 'denied',
'onDismissed' => 'cancelled'
]);
'onConfirmed' => [
'component' => 'livewire-component',
'listener' => 'confirmed'
];
$this->confirm('Are you sure do want to leave?', [
'onConfirmed' => 'confirmed',
]);
$this->flash('success', 'Successfully submitted form', [], '/');
[
'alert' => [
'position' => 'top-end',
'timer' => 3000,
'toast' => true,
'text' => null,
'showCancelButton' => false,
'showConfirmButton' => false
],
'confirm' => [
'icon' => 'warning',
'position' => 'center',
'toast' => false,
'timer' => null,
'showConfirmButton' => true,
'showCancelButton' => true,
'cancelButtonText' => 'No',
'confirmButtonColor' => '#3085d6',
'cancelButtonColor' => '#d33'
]
]
[
'customClass' => [
'container' => '',
'popup' => '',
'header' => '',
'title' => '',
'closeButton' => '',
'icon' => '',
'image' => '',
'content' => '',
'htmlContainer' => '',
'input' => '',
'inputLabel' => '',
'validationMessage' => '',
'actions' => '',
'confirmButton' => '',
'denyButton' => '',
'cancelButton' => '',
'loader' => '',
'footer' => ''
]
];
bash
php artisan vendor:publish --tag=livewire-alert:assets
bash
php artisan vendor:publish --tag=livewire-alert:config