Skip to content

Commit 9f116d4

Browse files
RVxLabfreekmurze
authored andcommitted
Only add the username property if it's not empty
1 parent 932c05e commit 9f116d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Notifications/Channels/Discord/DiscordMessage.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ public function fields(array $fields, bool $inline = true): self
114114

115115
public function toArray(): array
116116
{
117-
return [
118-
'username' => $this->username ?? 'Laravel Backup',
117+
$data = [
119118
'avatar_url' => $this->avatarUrl,
120119
'embeds' => [
121120
[
@@ -132,5 +131,11 @@ public function toArray(): array
132131
],
133132
],
134133
];
134+
135+
if (!empty($this->username)) {
136+
$data['username'] = $this->username;
137+
}
138+
139+
return $data;
135140
}
136141
}

0 commit comments

Comments
 (0)