1
|
|
|
<?php namespace Arcanesoft\Core\Traits; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class Notifyable |
5
|
|
|
* |
6
|
|
|
* @package Arcanesoft\Foundation\Traits |
7
|
|
|
* @author ARCANEDEV <[email protected]> |
8
|
|
|
*/ |
9
|
|
|
trait Notifyable |
10
|
|
|
{ |
11
|
|
|
/* ----------------------------------------------------------------- |
12
|
|
|
| Main Methods |
13
|
|
|
| ----------------------------------------------------------------- |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* The notify instance. |
18
|
|
|
* |
19
|
|
|
* @param string|null $message |
20
|
|
|
* |
21
|
|
|
* @return \Arcanedev\Notify\Contracts\Notify |
22
|
|
|
*/ |
23
|
|
|
protected function notify($message = null) |
24
|
|
|
{ |
25
|
|
|
return notify($message); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Notify a success alert. |
30
|
|
|
* |
31
|
|
|
* @param string $message |
32
|
|
|
* @param string|null $title |
33
|
|
|
* @param array $options |
34
|
|
|
*/ |
35
|
|
|
protected function notifySuccess($message, $title = null, array $options = []) |
36
|
|
|
{ |
37
|
|
|
$this->notifyFlash($message, 'success', $title, $options); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Notify a danger alert. |
42
|
|
|
* |
43
|
|
|
* @param string $message |
44
|
|
|
* @param string|null $title |
45
|
|
|
* @param array $options |
46
|
|
|
*/ |
47
|
|
|
protected function notifyDanger($message, $title = null, array $options = []) |
48
|
|
|
{ |
49
|
|
|
$this->notifyFlash($message, 'danger', $title, $options); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Notify a warning alert. |
54
|
|
|
* |
55
|
|
|
* @param string $message |
56
|
|
|
* @param string|null $title |
57
|
|
|
* @param array $options |
58
|
|
|
*/ |
59
|
|
|
protected function notifyWarning($message, $title = null, array $options = []) |
60
|
|
|
{ |
61
|
|
|
$this->notifyFlash($message, 'warning', $title, $options); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Notify an info alert. |
66
|
|
|
* |
67
|
|
|
* @param string $message |
68
|
|
|
* @param string|null $title |
69
|
|
|
* @param array $options |
70
|
|
|
*/ |
71
|
|
|
protected function notifyInfo($message, $title = null, array $options = []) |
72
|
|
|
{ |
73
|
|
|
$this->notifyFlash($message, 'info', $title, $options); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Notify a flash alert. |
78
|
|
|
* |
79
|
|
|
* @param string $message |
80
|
|
|
* @param string $type |
81
|
|
|
* @param string|null $title |
82
|
|
|
* @param array $options |
83
|
|
|
*/ |
84
|
|
|
protected function notifyFlash($message, $type, $title = null, array $options = []) |
85
|
|
|
{ |
86
|
|
|
$this->notify()->flash($message, $type, array_merge($options, compact('title'))); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|