e6f38d9481
* docs: remove requirement for setting APP_KEY manually * optimize date picker * clean up modals * spot light working * reorganization * add lazy load * wip * remove filament * styling
89 lines
2.5 KiB
PHP
89 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Traits;
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
|
|
trait Toast
|
|
{
|
|
public function toast(
|
|
string $type,
|
|
string $title,
|
|
?string $description = null,
|
|
?string $position = null,
|
|
string $icon = 'o-information-circle',
|
|
string $css = 'alert-info',
|
|
int $timeout = 3000,
|
|
?string $redirectTo = null
|
|
) {
|
|
$toast = [
|
|
'type' => $type,
|
|
'title' => $title,
|
|
'description' => $description,
|
|
'position' => $position,
|
|
'icon' => Blade::render("<x-ui.icon class='w-7 h-7' name='".$icon."' />"),
|
|
'css' => $css,
|
|
'timeout' => $timeout,
|
|
];
|
|
|
|
$this->js('toast('.json_encode(['toast' => $toast]).')');
|
|
|
|
// session()->flash('ib.toast.title', $title);
|
|
// session()->flash('ib.toast.description', $description);
|
|
|
|
if ($redirectTo) {
|
|
return $this->redirect($redirectTo, navigate: true);
|
|
}
|
|
}
|
|
|
|
public function success(
|
|
string $title,
|
|
?string $description = null,
|
|
?string $position = null,
|
|
string $icon = 'o-check-circle',
|
|
string $css = 'alert-success',
|
|
int $timeout = 3000,
|
|
?string $redirectTo = null
|
|
) {
|
|
return $this->toast('success', $title, $description, $position, $icon, $css, $timeout, $redirectTo);
|
|
}
|
|
|
|
public function warning(
|
|
string $title,
|
|
?string $description = null,
|
|
?string $position = null,
|
|
string $icon = 'o-exclamation-triangle',
|
|
string $css = 'alert-warning',
|
|
int $timeout = 3000,
|
|
?string $redirectTo = null
|
|
) {
|
|
return $this->toast('warning', $title, $description, $position, $icon, $css, $timeout, $redirectTo);
|
|
}
|
|
|
|
public function error(
|
|
string $title,
|
|
?string $description = null,
|
|
?string $position = null,
|
|
string $icon = 'o-x-circle',
|
|
string $css = 'alert-error',
|
|
int $timeout = 3000,
|
|
?string $redirectTo = null
|
|
) {
|
|
return $this->toast('error', $title, $description, $position, $icon, $css, $timeout, $redirectTo);
|
|
}
|
|
|
|
public function info(
|
|
string $title,
|
|
?string $description = null,
|
|
?string $position = null,
|
|
string $icon = 'o-information-circle',
|
|
string $css = 'alert-info',
|
|
int $timeout = 3000,
|
|
?string $redirectTo = null
|
|
) {
|
|
return $this->toast('info', $title, $description, $position, $icon, $css, $timeout, $redirectTo);
|
|
}
|
|
}
|