Skip to content

Commit

Permalink
Merge branch 'Okipa-issue-#64'
Browse files Browse the repository at this point in the history
  • Loading branch information
realrashid committed Jan 7, 2020
2 parents 1415c6f + ed5a73b commit 5e0d237
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/middleware.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Middleware

#### Using the Middleware
### Using the Middleware


First thing first
Expand All @@ -12,7 +12,11 @@ Let register the middleware in web middleware groups by simply adding the middle

into the `$middlewareGroups` of your `app/Http/Kernel.php` file.

> Note: Now all your validation errors will use SweetAlert2!
### Error messages auto displaying

Set the `SWEET_ALERT_AUTO_DISPLAY_ERROR_MESSAGES` .env value to `true` to activate the automatic displaying for the validation error messages.

By default, this is not activated.

### Examples

Expand Down
2 changes: 1 addition & 1 deletion src/ToSweetAlert.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handle($request, Closure $next)
alert()->info($request->session()->get('info'));
}

if ($request->session()->has('errors')) {
if ($request->session()->has('errors') && config('sweetalert.middleware.auto_display_error_messages')) {
$error = $request->session()->get('errors');

if (!is_string($error)) {
Expand Down
2 changes: 2 additions & 0 deletions src/config/sweetalert.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
'toast_close_button' => env('SWEET_ALERT_MIDDLEWARE_TOAST_CLOSE_BUTTON', true),

'alert_auto_close' => env('SWEET_ALERT_MIDDLEWARE_ALERT_AUTO_CLOSE', 5000),

'auto_display_error_messages' => env('SWEET_ALERT_AUTO_DISPLAY_ERROR_MESSAGES', false),
],

];

0 comments on commit 5e0d237

Please sign in to comment.