PHP code example of jeremykenedy / laravel-toast
1. Go to this page and download the library: Download jeremykenedy/laravel-toast 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/ */
jeremykenedy / laravel-toast example snippets
use Jeremykenedy\LaravelToast\Facades\Toast;
toast('Settings saved.');
toast('Upload failed.', 'error', 'Error');
Toast::warning('Low storage.', duration: 3000);
Toast::success('Step 1 done.')->info('Starting step 2.');
return back()->with('success', 'Profile updated.');
$this->dispatch('toast', message: 'Saved!', type: 'success');
$this->dispatch('toast-error', message: 'Upload failed.');
use Jeremykenedy\LaravelToast\Facades\Toast;
return array_merge(parent::share($request), [
'toasts' => function () {
if (config('toast.convert_flash', true)) {
Toast::convertFlashMessages();
}
return Toast::get();
},
]);
toast()->success('Saved!', 'Done', 3000, [
'position' => 'bottom-right',
'dir' => 'rtl',
'stack' => false,
'show_border' => false,
'enter_animation' => 'slide-right',
'exit_animation' => 'fade',
'progress_position' => 'bottom',
]);
use Jeremykenedy\LaravelToast\Facades\Toast;
Toast::success('Saved.');
Toast::error('Failed.', 'Error');
Toast::warning('Low storage.');
Toast::info('Update available.');
Toast::clear();
$this->dispatch('toast', message: 'Saved!', type: 'success', duration: 3000);
$this->dispatch('toast-success', message: 'Created!');
$this->dispatch('toast-error', message: 'Failed!');
$this->dispatch('toast-warning', message: 'Low storage.');
$this->dispatch('toast-info', message: 'Update available.');
$this->dispatch('toast', message: 'RTL toast', type: 'info', options: [
'dir' => 'rtl',
'exit_animation' => 'slide-left',
]);
use Illuminate\Support\Facades\Broadcast;
Broadcast::channel('toast.{userId}', function ($user, $userId) {
return (string) $user->getAuthIdentifier() === (string) $userId;
});
use Jeremykenedy\LaravelToast\Facades\Toast;
Toast::broadcast($user->getAuthIdentifier(), 'Your export is ready.', 'success');
bash
php artisan toast:switch --css=bootstrap5
npm run build
jsx
import ToastContainer from '../../../vendor/jeremykenedy/laravel-toast/resources/js/react/pages/ToastContainer.jsx'
export default function AppLayout({ children, toasts = [] }) {
return <>{children}<ToastContainer initialToasts={toasts} /></>
}
bash
php artisan vendor:publish --tag=toast-config
bash
php artisan vendor:publish --tag=toast-views
jsx
<ToastContainer initialToasts={toasts} channel={`toast.${user.id}`} echo={echo} />
bash
php artisan toast:update
php artisan toast:update --css=bootstrap5 --frontend=vue
bash
php artisan toast:switch --css=bootstrap5
php artisan toast:switch --frontend=livewire
bash
php artisan vendor:publish --tag=toast-config
php artisan vendor:publish --tag=toast-views
php artisan vendor:publish --tag=toast-lang
php artisan vendor:publish --tag=toast-css