|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\Components; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\View\Component; |
|
6
|
|
|
|
|
7
|
|
|
class Alert extends Component |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* The default icon for each alert theme. |
|
11
|
|
|
* |
|
12
|
|
|
* @var array |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $icons = [ |
|
15
|
|
|
'dark' => 'fas fa-bolt', |
|
16
|
|
|
'light' => 'far fa-lightbulb', |
|
17
|
|
|
'primary' => 'fas fa-bell', |
|
18
|
|
|
'secondary' => 'fas fa-tag', |
|
19
|
|
|
'info' => 'fas fa-info-circle', |
|
20
|
|
|
'success' => 'fas fa-check-circle', |
|
21
|
|
|
'warning' => 'fas fa-exclamation-triangle', |
|
22
|
|
|
'danger' => 'fas fa-ban', |
|
23
|
|
|
]; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The alert icon (a Font Awesome icon). |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
public $icon; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* The alert theme (dark, light, primary, secondary, info, success, warning |
|
34
|
|
|
* or danger). |
|
35
|
|
|
* |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
public $theme; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The alert title. |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
public $title; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Indicates if the alert is dismissable. |
|
49
|
|
|
* |
|
50
|
|
|
* @var bool|mixed |
|
51
|
|
|
*/ |
|
52
|
|
|
public $dismissable; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Create a new component instance. |
|
56
|
|
|
* |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
2 |
|
public function __construct( |
|
60
|
|
|
$theme = 'info', $icon = null, $title = null, $dismissable = null |
|
61
|
|
|
) { |
|
62
|
2 |
|
$this->theme = $theme; |
|
63
|
2 |
|
$this->icon = $icon ?? $this->icons[$theme]; |
|
64
|
2 |
|
$this->title = $title; |
|
65
|
2 |
|
$this->dismissable = $dismissable; |
|
66
|
2 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Make the class attribute for the alert item. |
|
70
|
|
|
* |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
1 |
|
public function makeAlertClass() |
|
74
|
|
|
{ |
|
75
|
1 |
|
$classes = ['alert', "alert-{$this->theme}"]; |
|
76
|
|
|
|
|
77
|
1 |
|
if (! empty($this->dismissable)) { |
|
78
|
1 |
|
$classes[] = 'alert-dismissable'; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
1 |
|
return implode(' ', $classes); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Get the view / contents that represent the component. |
|
86
|
|
|
* |
|
87
|
|
|
* @return \Illuminate\View\View|string |
|
88
|
|
|
*/ |
|
89
|
1 |
|
public function render() |
|
90
|
|
|
{ |
|
91
|
1 |
|
return view('adminlte::components.alert'); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|