Skip to content

Commit

Permalink
Only add the username property if it's not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
RVxLab authored and freekmurze committed Aug 7, 2024
1 parent d859659 commit 98b8b73
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Notifications/Channels/Discord/DiscordMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public function fields(array $fields, bool $inline = true): self

public function toArray(): array
{
return [
'username' => $this->username ?? 'Laravel Backup',
$data = [
'avatar_url' => $this->avatarUrl,
'embeds' => [
[
Expand All @@ -128,5 +127,11 @@ public function toArray(): array
],
],
];

if (!empty($this->username)) {
$data['username'] = $this->username;
}

return $data;
}
}

0 comments on commit 98b8b73

Please sign in to comment.