2023-04-20 17:50:49 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\View\Components;
|
|
|
|
|
|
|
|
use App\Abstracts\View\Component;
|
|
|
|
|
|
|
|
class Alert extends Component
|
|
|
|
{
|
|
|
|
/** @var bool */
|
|
|
|
public $rounded;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $border;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $color;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $icon;
|
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
/** @var string */
|
|
|
|
public $typr;
|
|
|
|
|
2023-04-20 17:50:49 +03:00
|
|
|
/** @var string */
|
|
|
|
public $title;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $description;
|
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
/** @var string */
|
|
|
|
public $message;
|
|
|
|
|
2023-04-20 17:50:49 +03:00
|
|
|
/** @var array */
|
|
|
|
public $list;
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
public $actions;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $dismiss;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new component instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
bool $rounded = true, bool $border = false,
|
|
|
|
|
|
|
|
string $color = '', string $icon = '',
|
2023-04-24 15:38:52 +03:00
|
|
|
|
|
|
|
string $type = '',
|
2023-04-20 17:50:49 +03:00
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
string $title = '', string $description = '', string $message = '',
|
2023-04-20 17:50:49 +03:00
|
|
|
array $list = [], array $actions = [],
|
|
|
|
bool $dismiss = false
|
|
|
|
) {
|
|
|
|
$this->rounded = $rounded;
|
|
|
|
$this->border = $border;
|
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
$this->type = $type;
|
|
|
|
|
2023-04-20 17:50:49 +03:00
|
|
|
$this->color = $this->getColor($color);
|
|
|
|
$this->icon = $this->getIcon($icon);
|
|
|
|
|
|
|
|
$this->title = $title;
|
|
|
|
$this->description = $description;
|
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
$this->message = $message;
|
|
|
|
|
2023-04-20 17:50:49 +03:00
|
|
|
$this->list = $list;
|
|
|
|
$this->actions = $actions;
|
|
|
|
|
|
|
|
$this->dismiss = $dismiss;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the view / contents that represent the component.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Contracts\View\View|string
|
|
|
|
*/
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('components.alert.index');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getColor($color)
|
|
|
|
{
|
|
|
|
if (! empty($color)) {
|
|
|
|
return $color;
|
|
|
|
}
|
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
switch ($this->type) {
|
|
|
|
case 'success':
|
|
|
|
$color = 'green';
|
|
|
|
break;
|
|
|
|
case 'info':
|
|
|
|
$color = 'blue';
|
|
|
|
break;
|
|
|
|
case 'warning':
|
|
|
|
$color = 'orange';
|
|
|
|
break;
|
|
|
|
case 'danger':
|
|
|
|
case 'error':
|
|
|
|
$color = 'red';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$color = 'green';
|
|
|
|
break;
|
|
|
|
}
|
2023-04-20 17:50:49 +03:00
|
|
|
|
|
|
|
return $color;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getIcon($icon)
|
|
|
|
{
|
|
|
|
if (! empty($icon)) {
|
|
|
|
return $icon;
|
|
|
|
}
|
|
|
|
|
2023-04-24 15:38:52 +03:00
|
|
|
switch ($this->type) {
|
|
|
|
case 'success':
|
|
|
|
$icon = 'check_circle';
|
|
|
|
break;
|
|
|
|
case 'info':
|
|
|
|
$icon = 'info';
|
|
|
|
break;
|
|
|
|
case 'warning':
|
|
|
|
$icon = 'warning';
|
|
|
|
break;
|
|
|
|
case 'danger':
|
|
|
|
case 'error':
|
|
|
|
$icon = 'error';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$icon = 'check_circle';
|
|
|
|
break;
|
|
|
|
}
|
2023-04-20 17:50:49 +03:00
|
|
|
|
|
|
|
return $icon;
|
|
|
|
}
|
|
|
|
}
|