@@ 20-35 (lines=16) @@ | ||
17 | * @param null $title |
|
18 | * @return \Illuminate\Http\JsonResponse |
|
19 | */ |
|
20 | public function notifyError($response, $title = null) |
|
21 | { |
|
22 | if (is_string($response)) { |
|
23 | $response = ['text' => $response]; |
|
24 | } |
|
25 | ||
26 | $default = [ |
|
27 | 'status' => false, |
|
28 | 'title' => $title ?: 'Error', |
|
29 | 'text' => 'Oops! An error occurred and we were not able to process your request!', |
|
30 | ]; |
|
31 | ||
32 | $data = array_diff_key($default, $response) + $response; |
|
33 | ||
34 | return $this->setNotificationType('error')->notify($data); |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * @param array $data |
|
@@ 73-88 (lines=16) @@ | ||
70 | * @param null|string $title |
|
71 | * @return \Illuminate\Http\JsonResponse |
|
72 | */ |
|
73 | public function notifySuccess($response, $title = null) |
|
74 | { |
|
75 | if (is_string($response)) { |
|
76 | $response = ['text' => $response]; |
|
77 | } |
|
78 | ||
79 | $default = [ |
|
80 | 'status' => true, |
|
81 | 'title' => $title ?: 'Success', |
|
82 | 'text' => 'Requested process successfully completed!', |
|
83 | ]; |
|
84 | ||
85 | $data = array_diff_key($default, $response) + $response; |
|
86 | ||
87 | return $this->setNotificationType('success')->notify($data, Response::HTTP_OK); |
|
88 | } |
|
89 | } |
|
90 | ||
91 |