+ Fix bug while sending mail v2

This commit is contained in:
Djery-Tom 2020-12-06 16:02:20 +01:00
parent d7981a2963
commit 4b6fe6f92f
1 changed files with 7 additions and 4 deletions

View File

@ -31,6 +31,7 @@ use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use PDO;
@ -60,8 +61,9 @@ trait Helper
$body->message = $message;
$body->data = $data;
try {
$body->date = $date->format('Y-m-d H:i:s');
} catch (\Exception $e) {
$body->date = ($date instanceof \DateTime) ? $date->format('Y-m-d H:i:s') : $date;
} catch (\Throwable $t) {
Log::error($t->getTraceAsString());
$body->date = $date;
}
$promise = $client->requestAsync('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers])->then();
@ -90,8 +92,9 @@ trait Helper
$body->message = $message;
$body->data = $data;
try {
$body->date = $date->format('Y-m-d H:i:s');
} catch (\Exception $e) {
$body->date = ($date instanceof \DateTime) ? $date->format('Y-m-d H:i:s') : $date;
} catch (\Throwable $t) {
Log::error($t->getTraceAsString());
$body->date = $date;
}
$promise = $client->requestAsync('POST', '/onesignal/pushToAgent', ['json' => $body, 'headers' => $headers])->then();