| Server IP : 3.138.164.131 / Your IP : 216.73.216.136 Web Server : Apache System : Linux ns1.techtime.me 4.18.0-147.8.1.el8.lve.1.x86_64 #1 SMP Mon Jun 29 09:55:57 EDT 2020 x86_64 User : injazaat ( 1471) PHP Version : 8.1.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/injazaat/public_html/vendor/realrashid/sweet-alert/src/ |
Upload File : |
<?php
namespace RealRashid\SweetAlert;
use Closure;
class ToSweetAlert
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
* @author Rashid Ali <realrashid05@gmail.com>
*/
public function handle($request, Closure $next)
{
if ($request->session()->has('success')) {
alert()->success($request->session()->get('success'));
}
if ($request->session()->has('info')) {
alert()->info($request->session()->get('info'));
}
if ($request->session()->has('warning')) {
alert()->warning($request->session()->get('warning'));
}
if ($request->session()->has('question')) {
alert()->question($request->session()->get('question'));
}
if ($request->session()->has('info')) {
alert()->info($request->session()->get('info'));
}
if ($request->session()->has('errors') && config('sweetalert.middleware.auto_display_error_messages')) {
$error = $request->session()->get('errors');
if (!is_string($error)) {
$error = $this->getErrors($error->getMessages());
}
alert()->error($error);
}
if ($request->session()->has('toast_success')) {
alert()->toast($request->session()->get('toast_success'), 'success')->middleware();
}
if ($request->session()->has('toast_info')) {
toast($request->session()->get('toast_info'), 'info')->middleware();
}
if ($request->session()->has('toast_warning')) {
toast($request->session()->get('toast_warning'), 'warning')->middleware();
}
if ($request->session()->has('toast_question')) {
toast($request->session()->get('toast_question'), 'question')->middleware();
}
if ($request->session()->has('toast_error')) {
toast($request->session()->get('toast_error'), 'error')->middleware();
}
return $next($request);
}
/**
* Get the validation errors
*
* @param object $errors
* @author Rashid Ali <realrashid05@gmail.com>
*/
private function getErrors($errors)
{
$errors = collect($errors);
return $errors->flatten()->implode('<br />');
}
}